65.9K
CodeProject is changing. Read more.
Home

nth Highest Salary in SQL Server 2005

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.80/5 (2 votes)

Feb 16, 2011

CPOL
viewsIcon

10201

SELECT TOP 1 salaryFROM (SELECT DISTINCT TOP n salaryFROM employeeORDER BY salary DESC) aORDER BY salarywhere n > 1SQL SERVER – Find Nth Highest Salary of Employee – Query to Retrieve the Nth Maximum value[^]

SELECT TOP 1 salary
FROM (
SELECT DISTINCT TOP n salary
FROM employee
ORDER BY salary DESC) a
ORDER BY salary
where n > 1
SQL SERVER – Find Nth Highest Salary of Employee – Query to Retrieve the Nth Maximum value[^]