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 |
abdbari
Starting Member
7 Posts |
Posted - 2013-09-17 : 22:26:33
|
Please help me how to write a query to count AGE by category (Exec or non Exec) sample are as follow: ----Age Group---------Category: Age <25 age 25-35 age 45-50 TotalExec 2 1 3Non Exec 10 5 5 20 Grand total: 23 Thanks. |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2013-09-17 : 22:50:39
|
[code]select category, count(case when age < 25 then age end) as [Age < 25], count(case when age >= 25 and age < 35 then age end) as [Age 25 - 35], . . . count(*) as Totalfrom yourtablegroup by category[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
abdbari
Starting Member
7 Posts |
Posted - 2013-09-17 : 23:34:25
|
Thanks will try it. |
 |
|
|
|
|