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
 General SQL Server Forums
 New to SQL Server Programming
 How to RANK 0 values at the bottom?

Author  Topic 

phrankbooth
Posting Yak Master

162 Posts

Posted - 2011-12-20 : 17:20:48
I have a result set that is like this:
empID, year, growth%

I'd like to RANK empID by highest growth%.

Sometimes the growth is 0.00 and I'd like those to be ranked last and not ranked as #1.

Any ideas appreciated, thanks!!

--PhB

etrek42
Starting Member

3 Posts

Posted - 2011-12-20 : 17:30:21
if i correctly understood your question ORDER BY should solve this.

SELECT empID FROM result
ORDER BY growth% DESC
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-12-21 : 03:09:35
You need to post some sample data with expected result

order by case when somevalue then 1 else 0 end, somevalue

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-12-21 : 03:28:32
[code]
ORDER BY case when growth = 0 then 2 else 1 end, growth
[/code]


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

Go to Top of Page
   

- Advertisement -