I have the following query which counts the instances of a certain field. This works just fine however it returns the results on 3 lines and what I need it to do it return this on just one line:
All input appreciated!
Thanks
Code:
select ofr.officername,
sum(case PCRatingID
when 1 then 1 else 0
end) as 'Excellent',
sum(case PCRatingID
when 2 then 1 else 0
end) as 'Satisfactory',
sum(case PCRatingID
when 3 then 1 else 0
end) as 'Unsatifactory'
from CustomerBaseMain cbm left join officers ofr
on cbm.officerid = ofr.officerid
inner join Plausibility pl
on cbm.AccountID = pl.AccountID
where cbm.actiondate between '01SEP2006' and '12APR2007'
and cbm.officerid in ('123456','654321','123654')
Group By ofr.officername, PCRatingID
All input appreciated!
Thanks