Archive
Posts Tagged ‘Nth Highest’
Select Find Nth Highest Salary Record In Sql Server
July 2, 2012
Leave a comment
1st Method :
SELECT TOP 1 [Salary]
FROM
(
SELECT DISTINCT TOP N [Salary]
FROM [dbo].[Employee]
ORDER BY [Salary] DESC
) temp
ORDER BY [Salary]
2nd Method :
SELECT * FROM
(
SELECT DENSE_RANK() OVER(ORDER BY [Salary] DESC)AS RowId, *
FROM [dbo].[Employee]
) AS e1
WHERE e1.RowId = N
http://csharpdotnetfreak.blogspot.com/2011/09/select-nth-highest-record-sql-server.html
Categories: SQL
Nth Highest
Recent Comments