Click here to Skip to main content
11,631,710 members (76,235 online)
Click here to Skip to main content
Articles » Database » Database » General » Alternatives
Alternatives (2)

Tagged as

nth Highest Salary in SQL Server 2005

, 16 Feb 2011 CPOL 16.8K 3


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.150723.1 | Last Updated 16 Feb 2011
Article Copyright 2011 by Mohd_Ahmad
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid