Interview › Self-join
SQL interview: employee / manager self-join
The manager is a row in the same table. Alias it twice.
Prompt. List each staff member and their manager’s name. Top person has no manager.
Hint: LEFT JOIN Staff m ON m.staff_id = s.manager_id
SELECT s.staff_id, s.full_name,
m.full_name AS manager_name
FROM Staff s
LEFT JOIN Staff m ON m.staff_id = s.manager_id;
A tree walk (all bosses above) is a recursive CTE, not one self-join.
Then write it on a ticket
Monday is free. A colleague asks, you type, we mark it.
Clock in free