You are given an Employees table with information about employees, their salaries, and their managers.
Task: Find the IDs of employees who meet both conditions:
- Their salary is strictly less than $30,000
- Their manager has left the company (manager exists in
manager_idbut not in the table)
When a manager leaves, their record is deleted from the table, but their former reports still have the manager_id pointing to the deleted manager.
Return results ordered by employee_id.
Table Schema
| Column Name | Type | Description |
|---|---|---|
employee_id
PK
|
int | Primary key, unique employee identifier |
name
|
varchar | Employee's full name |
manager_id
|
int | ID of the employee's manager, can be null |
salary
|
int | Employee's salary in dollars |
Input & Output
| employee_id | name | manager_id | salary |
|---|---|---|---|
| 3 | Mila | 9 | 60000 |
| 12 | Antonella | 9 | 25000 |
| 13 | Emery | 9 | 28000 |
| employee_id |
|---|
| 12 |
| 13 |
Employees 12 and 13 both have manager_id = 9, but there's no employee with employee_id = 9 in the table (the manager left). Employee 3 also has the same missing manager but earns 60000 ≥ 30000, so they're excluded. Only employees 12 and 13 meet both conditions: salary < 30000 AND manager left.
| employee_id | name | manager_id | salary |
|---|---|---|---|
| 1 | Boss | 80000 | |
| 2 | John | 1 | 25000 |
| employee_id |
|---|
Employee 1 is the boss with no manager (manager_id = null). Employee 2 has a valid manager (employee 1 exists) and salary < 30000, but since their manager didn't leave, they don't qualify. No employees meet both conditions.
| employee_id | name | manager_id | salary |
|---|---|---|---|
| 1 | Alice | 50000 | |
| 5 | Bob | 7 | 28000 |
| 6 | Carol | 7 | 35000 |
| employee_id |
|---|
| 5 |
Alice has no manager. Both Bob and Carol have manager_id = 7 (missing manager), but only Bob has salary < 30000. Carol's salary is 35000 ≥ 30000, so she's excluded.
Constraints
-
1 ≤ employee_id ≤ 100 -
1 ≤ name.length ≤ 20 -
1 ≤ manager_id ≤ 100 -
0 ≤ salary ≤ 100000