Search⌘ K

Solution to Exercise 4

Explore how to use nested SQL queries to find the second highest salary in a dataset. This lesson clarifies the use of WHERE clauses and subqueries, helping you understand practical query techniques and preparing you for advanced SQL concepts.

We'll cover the following...

Solution

MySQL
SELECT MAX(SALARY) AS SECOND_HIGHEST
FROM SALARY
WHERE SALARY < (SELECT MAX(SALARY) FROM SALARY);

Again, the solution will work without the SECOND_HIGHEST alias. ...