SQL Practice Logo

SQLPractice Online

Scenario SQL Question

Organizational Hierarchy - All Levels Using Recursive CTE

Build mastery in Self Joins Hierarchical with this scenario-based SQL challenge and live execution support.

Problem Statement

Use a recursive CTE to walk the org chart from CEO downward. For each row return employee_id, employee_name, manager_id, level (CEO=1), and hierarchy_path (the reporting chain shown as 'CEO -> VP -> ... -> employee'). Order by level, employee_id.

Relevant Tables

employees

SQL Concepts Used in This Scenario

Strengthen your understanding with these targeted learning topics: