SQL Interview Questions | Nth Highest Salary

Question
NAME SALARY Date of Joining
Angad 50,000 05 July
Bhuvan 52,000 19 March
Danish 77,000 06 September
Manhar 64,000 15 May
Shivraj 50,000 10 July
Tanuj 55,000 13 August

 

How will you get the data of the Nth highest salary from the table? Also, find the third highest salary by substituting values of N.

in progress 1
Dhruv2301 4 days 1 Answer 34 views Contributor 0

Answer ( 1 )

  1. select * from (
    select Name,salary,dense_rank() OVER(order by salary desc)r from employee)
    where r = n

    Note : To find the 3rd highest salary substitute n =3

Leave an answer

Browse
Browse