1WITH RECURSIVE org_tree AS (
2 -- Recursive member only — no base case
3 SELECT e.id, e.name, e.manager_id, 1 AS depth
4 FROM employees e
5 JOIN org_tree ot ON e.manager_id = ot.id
6 WHERE depth < 10
7)
8SELECT * FROM org_tree;
9-- Error: infinite recursion / missing non-recursive term
no lines flagged
#005PracticeHard35 min · 200 XP
Recursive CTE Missing Base Case
This recursive CTE to traverse an org chart runs forever and crashes the database. Find the missing line.
Flagged linesNo lines flagged yet
What's wrong?
Flag a line or write a note to submit.