Loading problem...
Your analytics team stores organizational compensation data in a single table:
id, name, salary, managerId)Each row describes one employee:
id is the employee identifiername is the employee namesalary is the employee salarymanagerId points to the direct manager's id (or is NULL for top-level leaders)Return all employees whose salary is strictly greater than the salary of their direct manager.
Output requirements:
Employee.managerId is NULL or does not match an existing employee, that row should not appear in the output.Solve this for both:
Employee:
| id | name | salary | managerId |
|----|--------|--------|-----------|
| 1 | Ira | 68000 | 3 |
| 2 | Noah | 76000 | 4 |
| 3 | Ravi | 65000 | NULL |
| 4 | Mina | 90000 | NULL |[
{"Employee":"Ira"}
]Ira earns 68,000 while manager Ravi earns 65,000, so Ira qualifies. Noah does not qualify because manager Mina earns more.
Employee:
| id | name | salary | managerId |
|----|--------|--------|-----------|
| 10 | Leo | 120000 | 12 |
| 11 | Kim | 98000 | 12 |
| 12 | Dana | 100000 | NULL |
| 13 | Omar | 130000 | 12 |[
{"Employee":"Leo"},
{"Employee":"Omar"}
]Both Leo and Omar earn more than manager Dana. Kim does not.
Employee:
| id | name | salary | managerId |
|----|--------|--------|-----------|
| 21 | Jia | 70000 | 22 |
| 22 | Pavel | 70000 | NULL |
| 23 | Tariq | 65000 | 22 |[]No employee has salary strictly greater than their direct manager.
Constraints