Second From the Top
Return one row with one column, second: the second highest salary in the table, counting equal salaries once. When there is no second salary (an empty table, or everyone on the same pay), second is NULL.
Example 1
employees
| id | name | salary |
|---|---|---|
| 1 | Ada | 5000 |
| 2 | Ben | 7000 |
| 3 | Cy | 7000 |
| 4 | Dee | 6000 |
returns
| second |
|---|
| 6000 |
Constraints
- Up to 10 people
Write it in your browser, against the clock. The model query, with a note on each piece of it, comes after.
More SQL problems
- Share of the TotalMedium
- Volume Weighted PriceMedium
- Chain of CommandHard
- Daily BarsHard
- Longest Winning StreakHard
- Median SalaryHard
- Month Over MonthHard
- Moving AverageHard