Employees Without a Manager
In the employees table, manager_id holds the emp_id of the person each employee reports to. Top-level people have a NULL manager_id.
List the employees who have no manager.
Return columns emp_id, name. Row order does not matter.
Schema
CREATE TABLE employees ( emp_id INTEGER PRIMARY KEY, name TEXT NOT NULL, manager_id INTEGER );
Sample data
employees
| emp_id | name | manager_id |
|---|---|---|
| 1 | Aisha Rahman | NULL |
| 2 | Ben Carter | 1 |
| 3 | Chen Wei | 1 |
| 4 | Divya Nair | 2 |
| 5 | Elena Petrova | 2 |
| 6 | Farid Haddad | 3 |
Hint 1
Comparing with = NULL is never true. Use IS NULL.
Hint 2
A manager_id of 0 is a value, not a missing manager.
Good practice for: Data Analyst, Backend Developer, Database Administrator
SQL (SQLite)
Run checks your query on the sample data (Ctrl + '). Submit also checks hidden databases.