select problemrecordedbytitle,problemstatus ,
count(problemstatus) from problemtable
where problemrecordedccyy >='2011'
and problemrecordedbytitle like 'LPM%'
group by problemrecordedbytitle, problemstatus
order by problemrecordedbytitle asc
LPM-AMS-EDW Open 1
LPM-AMS-EDW WIP 1
LPM-AMS-EOM Closed 4
this sql provides me with nice summary of statuses. however i got a new requirement today.
i want to sum of all ie count(problemstatus) and count(problemstatus<>closed) in summary.
it should be like
LPM-AMS-EDW NotClosed 2
LPM-AMS-EDW Total 6
I am not sure how i can do it in TSQL
You really should be careful not to group on fields with different values.
This will give you the result you are looking for as described.
I would rewrite it to this to prevent those group problems:
Result: