Share
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.
Best way to get the Nth highest salary from a table.
Table name – Employee
Columns – Emp_id, salary,depar
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