Scenario SQL Question
Hierarchy Level and Team Size for Each Employee
Build mastery in Self Joins Hierarchical with this scenario-based SQL challenge and live execution support.
Problem Statement
Write a recursive CTE to assign a level to each employee in the organizational hierarchy. Also calculate the team size (direct reports only) for each employee. Return employee_id, employee_name, hierarchy_level, and team_size.
Relevant Tables
employees
SQL Concepts Used in This Scenario
Strengthen your understanding with these targeted learning topics: