How do you get the fifth highest salary using self join?
Question
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
It will take less than 1 minute to register for lifetime. Bonus Tip - We don't send OTP to your email id Make Sure to use your own email id for free books and giveaways
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)