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 |
|
sardinka
Posting Yak Master
142 Posts |
Posted - 2004-07-06 : 11:04:11
|
| I have a query where my results displays like this:Answer IDYes 12No 12Yes 1Yes 1...I need to display my results like this:Answer IDYes No 12Yes No 1...How do I do this? |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2004-07-06 : 11:53:47
|
| Your sample data doesn't make sense...You have 'Yes' x2, but in your result you still have 'Yes No'What are you really trying to do??I will stab at it and say you want to know how many Yes and how many No for a given Id...With that assumption:Select Id, YesCnt = sum(Yes), NoCnt = sum(No)From ( Select Id, Yes = case when Answer='Yes' then 1 else 0 end, No = case when Answer='No' then 1 else 0 end, From ResultsTable ) as AGroup By IdCorey |
 |
|
|
|
|
|