Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
shagil.a.gopinath
Starting Member
14 Posts |
Posted - 2015-03-07 : 06:51:57
|
Hi,I have a table of status_Master where the details are maintained by street name with status but I need the result of total count by each status against the street name. Status_MasterSl No StreetName Status1        Delhi        Pending2        Delhi        Working3        Delhi        Working4        Mumbai        Pending5        Mumbai        Pending6        Delhi        Working7        Delhi        Problem8        Mumbai        Working9        Mumbai        Problem50        .        .100        .        .200        .        .Result as below StreetName Working Pending Problem Delhi               3            1            1 Mumbai            1            2            1 Can anyone please help me Thanks & Regards |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2015-03-07 : 08:24:48
|
[code]select StreetName, SUM(case when [Status] = 'Working' then 1 else 0 end) as Working, SUM(case when [Status] = 'Pending' then 1 else 0 end) as Pending, SUM(case when [Status] = 'Problem' then 1 else 0 end) as Problemfrom Status_Mastergroup by StreetName;[/code] |
|
|
shagil.a.gopinath
Starting Member
14 Posts |
Posted - 2015-03-07 : 11:20:04
|
Thanks you so much, its worked perfectly for the scenarioThanks & Regards |
|
|
|
|
|