How would you write a SQL query to find the second highest salary from a table?

  • SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM employees);
  • SELECT TOP 2 salary FROM employees ORDER BY salary DESC;
  • SELECT salary FROM employees ORDER BY salary DESC LIMIT 1 OFFSET 1;
  • SELECT salary FROM employees ORDER BY salary DESC LIMIT 1, 1;
To find the second highest salary, you can use the ORDER BY clause in descending order and apply LIMIT with an offset of 1 to retrieve the second highest salary from the table.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *