Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / database / SQL-Server

nth Highest Salary in SQL Server 2005

4.80/5 (2 votes)
16 Feb 2011CPOL 10.2K  
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[^]
SQL
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[^]

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)