Employees without a manager

SQL data engineering interview problem. Difficulty: beginner. Pattern: Missing Data. About 8 minutes. Free to practice.

In every company some people have no manager above them, such as the founder or the CEO. In the employees table, the manager_id column holds the employee_id of a person's boss. When someone has no boss, manager_id is empty (NULL). Find the employees who have no manager. Return their employee_id and name, sorted by employee_id.

Requirements

  • Keep only the rows where manager_id is NULL.
  • Check for NULL with IS NULL. Do not use = NULL.
  • Sort by employee_id from low to high.

Constraints

  • The table is employees.
  • Return only these 2 columns, in this order: employee_id, name.
  • Exactly one employee has no manager in this data.

Examples

Input: employees employee_id | name | manager_id 1 | Alice Chen | NULL 2 | Bob Kumar | 1 3 | Dan Park | 1 5 | Omar Ali | 1 Output: employee_id | name 1 | Alice Chen Why this passes: Only Alice has a NULL manager_id.

Topics: lakebench, sql, null, is null.

More SQL interview questions · All interview problems · Learn data engineering

beginner

Employees without a manager

Interview-style drill: Find employees whose manager_id is NULL.

Find employees with no manager (`manager_id IS NULL`). Columns: `employee_id`, `name`. Order by `employee_id`.