top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How will you find out 7th highest salary in a table?

+6 votes
460 views
How will you find out 7th highest salary in a table?
posted Dec 19, 2013 by Neeraj Pandey

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes
 
Best answer

CTE is best way of dealing such kind of problem

WITH CTE AS
(
SELECT EmpID,EmpName,EmpSalar,
RN = ROW_NUMBER() OVER (ORDER BY EmpSalary DESC)
FROM dbo.Salary
)
SELECT EmpID,EmpName,EmpSalar
FROM CTE
WHERE RN = @NthRow

answer Dec 23, 2013 by Prachi Agarwal
...