How do you get the fifth highest salary using self join? Question 5th highest salary in progress 1 SQL TheDataMonk 55 years 3 Answers 2071 views Grand Master 1
Answers ( 3 )
SELECT *
FROM employees E1
WHERE (SELECT COUNT(DISTINCT E2.Salary) FROM employees E2 WHERE E2.Salary >= E1.Salary) = 3
Select TOP 1 salary
FROM
(
Select TOP 5 salary
From Employee
Order BY salary DESC
) as E1
ORDER BY salary ASC
SELECT *
FROM employees t1
WHERE 5= (SELECT COUNT(DISTINCT t2.Salary) FROM employees t2 WHERE t2.Salary >= t1.Salary)