Median Salary
Return one row with one column, median: the middle salary when all salaries are lined up in order. With an even number of people it is the average of the two middle ones.
Example 1
employees
| id | name | salary |
|---|---|---|
| 1 | Ada | 5000 |
| 2 | Ben | 7000 |
| 3 | Cy | 3000 |
| 4 | Dee | 6000 |
returns
| median |
|---|
| 5500.0 |
Constraints
- 1 to 11 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
- Month Over MonthHard
- Moving AverageHard
- Position Over TimeHard
- SessionsHard
- Three Days RunningHard
- Top Two Salaries per DepartmentHard
- Worst DrawdownHard
- Between Two PricesBeginner