SQL Practice Logo

SQLPractice Online

Scenario SQL Question

Complex CTE Chain - Salary Growth Analysis

Build mastery in Ctes Window with this scenario-based SQL challenge and live execution support.

Problem Statement

Create a multi-level CTE analysis showing: (1) Monthly department salary expenses from history, (2) Month-over-month growth rates, (3) 3-month rolling averages, (4) Identify months with positive growth. Show department name, month, current expense, MoM growth %, rolling average, and growth indicator.

Relevant Tables

departmentsemployeessalaries_history