Scenario SQL Question
Monthly Salary Expense — MoM Growth & Rolling Average
Build mastery in Ctes Window with this scenario-based SQL challenge and live execution support.
Problem Statement
From salaries_history, build monthly salary expense per department (month = first 7 chars of effective_date, YYYY-MM). Then compute month-over-month growth %, a 3-month rolling average, and a has_growth flag. Return department_name, expense_month, monthly_expense, prev_month_expense, mom_growth_pct, rolling_3month_avg, has_growth — ordered by department_name, expense_month.
Relevant Tables
salaries_historyemployeesdepartments
SQL Concepts Used in This Scenario
Strengthen your understanding with these targeted learning topics: