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 |
|
Chengli
Starting Member
10 Posts |
Posted - 2008-07-19 : 00:51:20
|
| [code]i got the query problem ...How can i display the data like following:Aid Total Count(astatus)------------------- A1 1 A2 0if the sample data given is like following:Aid ACid AStatus------------------- A1 1 Yes A1 1 NO A2 2 No A2 2 NOThanks for helps....[/code] |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-19 : 01:24:57
|
| SELECT Aid,SUM(CASE WHEN AStatus='Yes' THEN 1 ELSE 0 END) AS [Total Count]FROM YourTableGROUP BY Aid |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-07-19 : 01:27:32
|
select aid, sum(case when astatus = 'yes' then 1 else 0 end)from table1group by aidorder by aidselect aid, count(nullif(astatus, 'no'))from table1group by aidorder by aid E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|
|
|