Click here to Skip to main content
12,898,516 members (62,543 online)
Click here to Skip to main content
Articles » Database » Database » General » Alternatives
Alternatives (2)
Add your own
alternative version


3 bookmarked
Posted 16 Feb 2011

nth Highest Salary in SQL Server 2005

, 16 Feb 2011 CPOL


Members may post updates or alternatives to this current article in order to show different approaches or add new features.

16 Feb 2011
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[^]
18 Apr 2011
Costica U
The original solution has some issues. Check the following script:IF OBJECT_ID('tempdb..#salary') IS NOT NULL BEGIN DROP TABLE #salary ENDCREATE TABLE #salary ( Salary INT )INSERT INTO #salary(Salary) VALUES(5) -- 1INSERT INTO #salary(Salary)...


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


About the Author

India India
No Biography provided

| | Privacy | Terms of Use | Mobile
Web01 | 2.8.170424.1 | Last Updated 16 Feb 2011
Article Copyright 2011 by Mohd_Ahmad
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid