Find the Nth largest salary from employee table.
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 (select *, dense_rank() over(order by salary DESC) highest_salary from employee) where highest_salary = n;
Select salary from Employee
order by salary desc
limit n-1,1
Use OFFSET and LIMIT to get the Nth highest salary. We can use Dense_Rank() or Sub Query to get the same output.
Select Salary from Employee
ORDER BY Salary Desc
LIMIT n-1 ,1