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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 simple question tsql

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 guys

I currently have a query

SELECT 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 counts


Instead 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 totalGuys
from tblUserDetails [/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

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 totalGuys
from tblUserDetails



KH
[spoiler]Time is always against us[/spoiler]





thank you khtan!! :)

Go to Top of Page

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]

Go to Top of Page
   

- Advertisement -