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.

nth highest

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:

nth highest

2.  Using CO-RELATED Query:

nth highest

3.  Using LEVEL function:

nth highest

4.  Using RANK Function:

nth highest

5.  Using ROW_NUMBER function

nth highest

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

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.