← All SQL interview questions
Build each employee's reporting chain to the CEO
HardRecursive CTEsTargetOracle
An access-review tool must display the full escalation chain for each person.
org_members stores reports_to as a self-reference; the CEO's is NULL. Using a recursive CTE, return member_id, member_name, levels_from_top (0 for the CEO) and chain — the names from the CEO down to that member joined with -> .
Sample data
More Recursive CTEs questions
Practising alone only goes so far — our live cohorts pair SQL depth with dashboards, agentic analytics projects and mock interviews.
Explore the program