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 |
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2008-06-26 : 22:28:14
|
| Hi,I can't seem to remember or find any examples on how to do this. I think it will be really easy for one of you guysI currently have a querySELECT count(userID) as totalMembers FROM tblUserDetails WHERE active = 1 However I want to change the data being brought back so that it brings back both girl counts and guy countsInstead of "totalmembers / 350" being brought back.I would like "totalGirls / 150 | totalGuys / 120" being brought back. Any help much appreciated !!thanks,mike123 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-06-26 : 22:30:38
|
[code]select count(case when sex = 'F' then userID end) as totalGirls, count(case when sex = 'M' then userID end) as totalGuysfrom tblUserDetails [/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2008-06-26 : 22:34:01
|
quote: Originally posted by khtan
select count(case when sex = 'F' then userID end) as totalGirls, count(case when sex = 'M' then userID end) as totalGuysfrom tblUserDetails KH[spoiler]Time is always against us[/spoiler]
thank you khtan!! :) |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2008-06-26 : 22:42:23
|
you are welcome KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|