More Than the Manager
manager_id is the id of a person's manager, a row of the same table (NULL for people with none). Return the name of everyone who earns more than their own manager. Rows may come in any order.
Example 1
employees
| id | name | salary | manager_id |
|---|---|---|---|
| 1 | Ada | 9000 | NULL |
| 2 | Ben | 9500 | 1 |
| 3 | Cy | 4000 | 1 |
| 4 | Dee | 4000 | 3 |
returns
| name |
|---|
| Ben |
Constraints
- Up to 12 people
- Names are unique
Write it in your browser, against the clock. The model query, with a note on each piece of it, comes after.
More SQL problems
- Open PositionsMedium
- Rank in the DepartmentMedium
- Revenue per CityMedium
- Running BalanceMedium
- Second From the TopMedium
- Share of the TotalMedium
- Volume Weighted PriceMedium
- Chain of CommandHard