Click here to Skip to main content
13,149,427 members (54,125 online)
Click here to Skip to main content
Add your own
alternative version

Stats

20.2K views
3 bookmarked
Posted 16 Feb 2011

nth Highest Salary in SQL Server 2005

, 16 Feb 2011
Rate this:
Please Sign up or sign in to vote.
SELECT salary FROM TN a 
    WHERE n - 1 = (SELECT COUNT(salary) FROM TN b WHERE b.salary > a.salary)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Mohd_Ahmad
India India
This member doesn't quite have enough reputation to be able to display their biography and homepage.

You may also be interested in...

Pro
Pro

Comments and Discussions

 
GeneralRe: Looks like you have not modified your vote yet. There is sti... Pin
AspDotNetDev22-Feb-11 14:44
protectorAspDotNetDev22-Feb-11 14:44 
GeneralRe: You're right :) *ashamed* I'll modify my vote. Pin
phil.o22-Feb-11 8:17
memberphil.o22-Feb-11 8:17 
GeneralReason for my vote of 1 There are some issues with your quer... Pin
Costica U2-Mar-11 13:55
memberCostica U2-Mar-11 13:55 
GeneralReason for my vote of 1 First, the SQL request you give seem... Pin
phil.o17-Feb-11 5:46
memberphil.o17-Feb-11 5:46 
Reason for my vote of 1
First, the SQL request you give seems a little bit obscure.
Second, you can reach that goal simply with :
SELECT TOP 1 salary FROM TN ORDER BY salary DESC
GeneralRe: I think you are being a little hard here. The Subject says ... Pin
Henry Minute17-Feb-11 14:41
memberHenry Minute17-Feb-11 14:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170924.2 | Last Updated 16 Feb 2011
Article Copyright 2011 by Mohd_Ahmad
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid