Report Employees Whose Pay Exceeds Their Manager’s
Quick Overview
Find each employee whose salary is strictly greater than the salary of the manager identified by managerId. Return the employee name in a column named Employee, with no required row ordering.
Report Employees Whose Pay Exceeds Their Manager’s
Company: Google
Role: Software Engineer
Category: Data Manipulation (SQL/Python)
Difficulty: easy
Interview Round: Other
### Problem
Find each employee whose salary is strictly greater than the salary of the manager identified by managerId. Return the employee name in a column named Employee, with no required row ordering.
### Tables
Table: `Employee`
```text
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| id | int |
| name | varchar |
| salary | int |
| managerId | int |
+-------------+---------+
id is the primary key (column with unique values) for this table.
Each row of this table indicates the ID of an employee, their name, salary, and the ID of their manager.
```
### Example
```text
Employee (id,name,salary,managerId): (1,Ada,75,3), (2,Bo,60,3), (3,Cam,60,NULL)
Output (Employee): (Ada)
```
### What a Strong Answer Covers
- Compare each employee with their own manager.
- Apply the strict salary comparison and handle an employee with no manager.
- Return the requested column, retaining qualifying rows even when names match.
### Follow-up Questions
- What changes if the result must also include the manager’s name?
- How should ties be handled if the comparison rule changes to “earns at least as much”?
Overview: Find each employee whose salary is strictly greater than the salary of the manager identified by managerId. Return the employee name in a column named Employee, with no required row ordering.
Find each employee whose salary is strictly greater than the salary of the manager identified by managerId. Return the employee name in a column named Employee, with no required row ordering.
Tables
Table: Employee
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| id | int |
| name | varchar |
| salary | int |
| managerId | int |
+-------------+---------+
id is the primary key (column with unique values) for this table.
Each row of this table indicates the ID of an employee, their name, salary, and the ID of their manager.