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 |
adiboy0420
Starting Member
10 Posts |
Posted - 2012-07-11 : 00:19:56
|
Please Helpquestion: i need the > 71 to show on the bottom of the list, right now as you can see it is on top!!! so > 71 needs to after age 61-70 so how do i do that ?!? please helpthis is my resultagegroup Number of people> 71 130-40 12241-50 10651-60 4161-70 20-----------------my code :select a.Agegroup, SUM(a.[Number of People]) as 'Number of people'from (select DATEDIFF(year,birthdate,getdate())as Age, COUNT(DATEDIFF(year,birthdate,getdate())) as 'Number of People',case whenDATEDIFF(year,birthdate,getdate())between 30 and 40 then '30-40'when DATEDIFF(year,birthdate,getdate()) between 41 and 50 then'41-50'when DATEDIFF(year,birthdate,getdate()) between 51 and 60 then '51-60'when DATEDIFF(year,birthdate,getdate()) between 61 and 70 then '61-70'when DATEDIFF(year,birthdate,getdate()) between 71 and 80 then '> 71'end as 'Agegroup'from HumanResources.Employeegroup by DATEDIFF(year,birthdate,getdate()))as Agroup by a.Agegroup |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2012-07-11 : 04:08:20
|
[code]ORDER BY CASE WHEN [AgeGroup] = '> 71' THEN 1 ELSE 0 END ASC , [AgeGroupp] ASC[/code]after the group by statement would probably work.Transact CharlieMsg 3903.. The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION. |
 |
|
adiboy0420
Starting Member
10 Posts |
Posted - 2012-07-11 : 12:08:06
|
That worked perfect. thankyou so much |
 |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2012-07-11 : 12:31:03
|
welcome.Transact CharlieMsg 3903.. The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION. |
 |
|
|
|
|
|
|