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 |
|
benko
Starting Member
24 Posts |
Posted - 2004-11-25 : 11:26:24
|
| Ok im doing a simple query from one table. The columns im getting are the date but i also need a column for a count for YES and a column count for NO. My where clause in where status is YES or where status is NO. How do i get the count for those 2 columns. Thanks in advance. Select theDate, someCount?, someCount?from tblstatuswhere status='YES' OR status='NO'I DUNNO?!! |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-11-25 : 11:48:57
|
Will this do:select theDate, sum(case when status='YES' then 1 else 0 end) as YesCount,sum(case when status='NO' then 1 else 0 end) as NoCountfrom tblstatuswhere status='YES' OR status='NO'group by theDateGo with the flow & have fun! Else fight the flow |
 |
|
|
|
|
|