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 |
|
Scott
Posting Yak Master
145 Posts |
Posted - 2002-12-17 : 03:00:58
|
| I have a sql statement that is counting on a condition:SELECT 'totbm' as [type], COUNT(*)as tot, cat from dbo.View_HR_PersonSummary WHEREGENDER = 'Male'AND RACE = 'black'and cat = @pcat group by cathowever when the condition is not met, i require a 0 to be returned it the tot column, so that the record set is for all conditions.any suggestions? |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-12-17 : 03:51:58
|
| SELECT 'totbm' as [type], sum(case when GENDER = 'Male'AND RACE = 'black'and cat = @pcat then 1 else 0 end) as tot, cat from dbo.View_HR_PersonSummarygroup by cat ==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|