shlogg · Early preview
Pranav Bakare @mrcaption49

Finding Second Highest Salary With Oracle SQL Methods

6 ways to find the 2nd highest salary in Oracle SQL: Subquery, ORDER BY with ROWNUM, RANK() & DENSE_RANK(), GROUP BY with HAVING, Common Table Expression (CTE) and more!

Finding the second highest salary in Oracle SQL can also be approached in multiple ways. Here are various methods to achieve this, including problem statements and explanations for each approach.
Problem Statement
Find the second highest salary from the employees table.
Sample Data
Assuming the same employees table:


employee_id
first_name
last_name
salary
department_id


1
John
Doe
60000
10

2
Jane
Smith
70000
20

3
Alice
Johnson
80000
10

4
Bob
Brown
75000
20

5
Charlie
Davis
90000
30


Solution 1: Using a Subquery
SELECT MAX(salary) AS second_highest_salary
FROM employees
WHERE salary < (S...