About the “Recursive Employee Reporting Chain & Hierarchy Depth” SQL Problem
Business Scenario
Enterprise org design mandates calculating management span and chain-of-command depth. Using a Recursive CTE, traverse the corporate org hierarchy to determine every employee's depth relative to the CEO (Level 1).
Expected Output & Criteria
Employee hierarchy showing reporting depth distance from the executive level.
Database Table Schema (PostgreSQL DDL)
PostgreSQL 16 WASMThis challenge executes directly against the following relational schema in your browser:
CREATE TABLE corporate_hierarchy (
emp_id INT PRIMARY KEY,
emp_name VARCHAR(100) NOT NULL,
manager_id INT REFERENCES corporate_hierarchy(emp_id)
);Target SQL Clauses & Operators
Want more CTEs practice?
Explore the full syllabus of 12 exercises, syntax guides, and interview pitfalls.