Find the Nth largest salary from employee table.

Question

Best way to get the Nth highest salary from a table.
Table name – Employee
Columns – Emp_id, salary,depar

in progress 1
Ritika Sohal 55 years 3 Answers 1187 views Member 0

Answers ( 3 )

    0

    select * from (select *, dense_rank() over(order by salary DESC) highest_salary from employee) where highest_salary = n;

  1. Select salary from Employee
    order by salary desc
    limit n-1,1

  2. 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

Leave an answer

Browse
Browse