Q How to find the nth highest salary from a table in SQL Server ?
Consider below the EmployeeDetails table.
Let us target to find 2nd highest salary from above table which is 40000.
We can achieve this in the following two ways:
By using TOP clause
SELECT TOP 1 Salary FROM
(SELECT DISTINCT TOP 2 Salary
FROM EmployeeDetails
ORDER BY Salary DESC) A
ORDER BY Salary
Consider below the EmployeeDetails table.
![]() |
| EmployeeDetails Table |
Let us target to find 2nd highest salary from above table which is 40000.
We can achieve this in the following two ways:
By using TOP clause
SELECT TOP 1 Salary FROM
(SELECT DISTINCT TOP 2 Salary
FROM EmployeeDetails
ORDER BY Salary DESC) A
ORDER BY Salary
