SQL 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 (n is always greater than one)
FROM (
SELECT DISTINCT TOP n salary
FROM employee
ORDER BY salary DESC) a
ORDER BY salary
But I need a high performance query which won't sort and use top....
ReplyDelete