Write a query to find the second highest salary from an employee table.

1 Answers
Answered by suresh

Query to Find Second Highest Salary in Oracle

Query to Find Second Highest Salary in Oracle

To find the second highest salary from an employee table in Oracle, you can use the following SQL query:


    SELECT MAX(salary) AS second_highest_salary 
    FROM employees 
    WHERE salary < (SELECT MAX(salary) FROM employees);
  

This query first identifies the highest salary in the employee table using the MAX function. Then, it retrieves the maximum salary that is less than the highest salary to get the second-highest salary.

Answer for Question: Write a query to find the second highest salary from an employee table.