Click here to Skip to main content
15,880,905 members
Articles / Database Development / SQL Server
Tip/Trick

nth Highest Salary in SQL Server 2005

Rate me:
Please Sign up or sign in to vote.
3.33/5 (3 votes)
16 Feb 2011CPOL 25.3K   3   5
SQL
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)


Written By
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

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
professionalphil.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
Costica 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
professionalphil.o17-Feb-11 5:46 
GeneralRe: I think you are being a little hard here. The Subject says ... Pin
Henry Minute17-Feb-11 14:41
Henry 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.