how to get specific salary in sql 1

how to get specific salary in sql

Here is the solution for nth highest
salary from employees table 

SELECT FIRST_NAME , SALARY FROM 
(SELECT FIRST_NAME, SALARY, DENSE_RANK() OVER
(ORDER BY SALARY DESC) AS SALARY_RANK
FROM EMPLOYEES)
WHERE SALARY_RANK = n; 

Here is what the above code is Doing:
1. The inner query is used to find the rank of each record in a partition.
2. The outer query is then used to filter records for a given rank.

Similar Posts