Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
5
Reply
** Please solve this group by query...
Venkatesan
May 23 2013 4:07 AM
1.1k
Reply
1) My Table:
Query: select mcdesp,mcopsts from machine
Table:
mcdesp
mcopsts
A
GOOD
A
GOOD
B
GOOD
C
URWP
C
GOOD
A
URWT
A
URWT
2) My Quries and their outputs:
select mcdesp,count(mcopsts)as TotalMachine from machine group by mcdesp
mcdesp
TotalMahine
A
4
B
1
C
2
select mcdesp, count(mcopsts) as GOOD from machine where mcopsts='GOOD' group by mcdesp
mcdesp
GOOD
A
2
B
1
C
1
select mcdesp,count(mcopsts) as URWT from machine where mcopsts='URWT' group by mcdesp
mcdesp
URWT
A
2
B
C
select mcdesp,count(mcopsts) as URWP from machine where mcopsts='URWP' group by mcdesp
mcdesp
URWP
A
B
C
1
BUT I NEED A RESULT LIKE
mcdesp
TotalMachine
GOOD
URWP
URWT
A
4
2
0
2
B
1
1
0
0
C
2
1
1
0
Please some one help me..
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
5
)
Next Recommended Forum
image url in sql server 2008
SQL SERVER TEMP TABLE