Employees Earning More Than Their Manager
Problem statement
The employees table contains one row per employee, including their salary and the ID of their direct manager.
Return the employee_id and employee_name of every employee whose salary is strictly greater than their direct manager's salary. Sort the result by employee_id in ascending order.
A null manager ID means the employee has no manager and must be excluded. Every non-null manager ID refers to an employee in the table. Employees with equal salaries do not qualify. Compare only with the direct manager, even when a management chain contains more people. Different employees may have the same name.
Table schema
Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.
employees
One row per employee and their direct manager.
| Column | Type | Nullable | Description |
|---|---|---|---|
| employee_idPK | Integer | No | — |
| employee_name | Text | No | — |
| salary | Integer | No | — |
| manager_id | Integer | Yes | — |
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| employee_id | Integer | No | — |
| employee_name | Text | No | — |
Row order: must match exactly. Numeric tolerance: 0.
Constraints
- The table contains between 0 and 10^4 rows.
employee_idis unique and between 1 and 10^9.employee_nameis nonempty text of at most 100 characters.salaryis an integer between 0 and 10^9.- An employee cannot be their own manager. Management chains are acyclic.