Find Low-Paid Employees Whose Recorded Manager Row Is Gone

Quick Overview

Find low-paid employees whose recorded manager ID no longer identifies an employee, and return their IDs in order.

Find Low-Paid Employees Whose Recorded Manager Row Is Gone

Company: Amazon

Role: Software Engineer

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

### Problem Return employee_id for employees paid strictly less than 30000 whose non-NULL manager_id no longer identifies any Employees row. A NULL manager_id means no manager, not a manager who left. Sort employee_id ascending. ### Tables Table: `Employees` ```text +-------------+----------+ | Column Name | Type | +-------------+----------+ | employee_id | int | | name | varchar | | manager_id | int | | salary | int | +-------------+----------+ In SQL, employee_id is the primary key for this table. This table contains information about the employees, their salary, and the ID of their manager. Some employees do not have a manager (manager_id is null). ``` ### Example ```text Employees (employee_id,name,manager_id,salary): (1,Ada,9,29999), (2,Bo,NULL,20000), (3,Cam,4,25000), (4,Dee,NULL,50000), (5,Eli,8,30000) Output (employee_id): (1) ``` ### What a Strong Answer Covers - Apply the strict salary cutoff and require a recorded manager ID. - Return employees whose recorded manager is absent and sort the requested IDs. ### Follow-up Questions - How would you report employees whose manager exists but is marked inactive? - How would you identify the missing manager IDs with the most affected employees?

Overview: Find low-paid employees whose recorded manager ID no longer identifies an employee, and return their IDs in order.

Amazon logo
Amazon
easySoftware EngineerOtherData Manipulation (SQL/Python)
0
0

Problem

Return employee_id for employees paid strictly less than 30000 whose non-NULL manager_id no longer identifies any Employees row. A NULL manager_id means no manager, not a manager who left. Sort employee_id ascending.

Tables

Table: Employees

+-------------+----------+
| Column Name | Type     |
+-------------+----------+
| employee_id | int      |
| name        | varchar  |
| manager_id  | int      |
| salary      | int      |
+-------------+----------+
In SQL, employee_id is the primary key for this table.
This table contains information about the employees, their salary, and the ID of their manager. Some employees do not have a manager (manager_id is null).

Example

Employees (employee_id,name,manager_id,salary): (1,Ada,9,29999), (2,Bo,NULL,20000), (3,Cam,4,25000), (4,Dee,NULL,50000), (5,Eli,8,30000)
Output (employee_id): (1)

What a Strong Answer Covers Guidance

  • Apply the strict salary cutoff and require a recorded manager ID.
  • Return employees whose recorded manager is absent and sort the requested IDs.

Follow-up Questions Guidance

  • How would you report employees whose manager exists but is marked inactive?
  • How would you identify the missing manager IDs with the most affected employees?