66. Everyone Who Reports Up To A Manager
A recursive CTE walks a hierarchy: the anchor picks the starting rows, and the recursive member repeatedly joins the table back onto the rows found so far until nothing new appears. This computes the transitive closure — every node reachable from the start.
The employees table is a self-referencing tree: manager_id points at another employee's id (the CEO has NULL).
Task: list everyone who reports up to Alice (id 1), directly or indirectly — i.e. her whole sub-tree, excluding Alice herself. Also report each person's depth below Alice (direct reports = 1).
Return columns name, depth, ordered by depth ascending, then name ascending.
This is the result for the example data above. On Submit your query is graded against this example plus 4 hidden edge cases — 5test cases in all. A sloppy query that only fits the example won't pass.