SQL Practice Logo

SQLPractice Online

Scenario SQL Question

Department Hierarchy with Budget Rollup

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

Problem Statement

Write a recursive CTE to display department hierarchy and calculate cumulative budget including all child departments. Return department_id, department_name, parent_department_id, budget, cumulative_budget, and hierarchy_level.

Relevant Tables

departments

SQL Concepts Used in This Scenario

Strengthen your understanding with these targeted learning topics: