Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How to get the 5th highest salary from the table. Suppose, I have 100 rows and I want to display details of 5th highest salary of the individual then how to write that query in T-SQL using SQL Server 2008R2.

1 emp1 1000
2 emp2 2000
3 emp3 3000
4 emp4 4000
5 emp5 5000
6 emp6 6000
7 emp7 7000
8 emp8 8000
9 emp9 9000
share|improve this question

closed as not a real question by Paul White, Mat, dezso, Jon Seigel, RolandoMySQLDBA May 8 '13 at 15:03

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

What should happen on ties? – ypercubeᵀᴹ May 8 '13 at 6:10
This a bad question. Will everyone have different salaries? How at ties handled at places 1-4+ At 5+? Is is DENSE_RANK or RANK you want? – gbn May 8 '13 at 10:31
with salaryCTE AS
 select ROW_NUMBER() over(order by AnnualSalary desc) AS Ranking,*
 from salary -- employe salary table
 select * from salaryCTE where Ranking=5
share|improve this answer
how about ties? Use DENSE_RANK() instead. – Remus Rusanu May 8 '13 at 5:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.