5
Answers

** Please solve this group by query...

Venkatesan

Venkatesan

11y
1.2k
1

1) My Table:

Query: select mcdesp,mcopsts from machine

Table:  

mcdespmcopsts
AGOOD
A GOOD
BGOOD
CURWP
CGOOD
AURWT
AURWT


2)  My Quries and their outputs:


select mcdesp,count(mcopsts)as TotalMachine from machine group by mcdesp

mcdespTotalMahine
A4
B1
C2

select mcdesp, count(mcopsts) as GOOD from machine where mcopsts='GOOD' group by mcdesp

mcdespGOOD
A2
B1
C1

select mcdesp,count(mcopsts) as URWT from machine where mcopsts='URWT' group by mcdesp
mcdespURWT
A2
B
C

select mcdesp,count(mcopsts) as URWP from machine where mcopsts='URWP' group by mcdesp

mcdespURWP
A
B
C1


BUT I NEED A RESULT LIKE 

mcdespTotalMachineGOODURWPURWT
A4202
B1100
C2110


Please some one help me..

Answers (5)