The highest-paid employee is easy to find. The second-highest is where it gets interesting. Using the employees table, find the second highest salary. If there's only one distinct salary value, return NULL.
employees
| column | type |
|---|---|
| id | INTEGER |
| name | TEXT |
| department | TEXT |
| salary | INTEGER |
| id | name | department | salary |
|---|---|---|---|
| 1 | Alice | Engineering | 120000 |
| 2 | Bob | Marketing | 85000 |
| 3 | Carol | Engineering | 135000 |
| 4 | Dave | HR | 72000 |
| second_highest_salary |
|---|
| 120000 |
Carol has the highest salary (135,000). Alice is next at 120,000, making it the second highest salary in the table.