Employees Earning More Than Their Manager
Updated
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.
More Mygate Phone Screen questions
- Maximum Subarray SumPHONE SCREEN · Seen Sep 2026
- Reverse a Linked ListPHONE SCREEN · Seen Sep 2026
- Users Active in Both January and FebruaryPHONE SCREEN · Seen Sep 2026
- Elements Occurring More Than n/3 TimesPHONE SCREEN · Seen Jan 2025
- Frog Jump: Minimum EnergyPHONE SCREEN · Seen Jan 2025
- Left View of a Binary TreePHONE SCREEN · Seen Jan 2025
- Two SumPHONE SCREEN · Seen Aug 2024
- Minimum in a Rotated Sorted ArrayPHONE SCREEN · Seen Jul 2024
- Minimum Subarray SumPHONE SCREEN · Seen Sep 2023
- Remove the Nth Node from the EndPHONE SCREEN · Seen Sep 2023
Similar questions at other companies
- Second Highest SalaryPaytm · PHONE SCREENPaytm interview questions
- Employees Who Earn More Than Their ManagersNykaa · PHONE SCREENNykaa interview questions
- Employees Who Joined More Than a Week AgoNewgen Software · PHONE SCREEN
- Departments Without EmployeesDell Technologies · PHONE SCREENDell Technologies interview questions
- Second-Highest Distinct SalaryChubb · PHONE SCREENChubb interview questions
- Swap Two Gender ValuesInfosys · PHONE SCREENInfosys interview questions
- Find Rows Common to Two TablesSalesforce · PHONE SCREENSalesforce interview questions
- Count Records Present in A but Not BCapital One · PHONE SCREENCapital One interview questions
- Customer Order Count Distribution by CountryApple · PHONE SCREENApple interview questions
- Classify Tree Nodes with SQLOracle · PHONE SCREENOracle interview questions