Best way to find the Nth Highest Salary of Employee in Oracle
This is one of the most common and most frequently asked question in the interview. There are many ways to solve this question but today we are going to see the best and fasted approach to resolve this.
Here, I am taking example of given below EMP Table where we have to retrieve the nth highest SAL from column have duplicate values.
Now, I am going to find the 4th highest salary from EMP table. So, we should get record having value 2850 in SAL column.
Let’s see what are different ways to retrieve it.
1. Using DENSE_RANK function:
2. Using CO-RELATED Query:
3. Using LEVEL function:
4. Using RANK Function:
5. Using ROW_NUMBER function
As shown above, we have many ways to find the Nth highest value. If you have any comments then please let me know by commenting below. You can download all queries by clicking on download icon below