About the “Departmental Headcount and Compensation Budget Cap” SQL Problem
Business Scenario
FP&A finance controllers monitor departmental payroll spend against annual operating budget allocations to flag departments nearing compensation caps.
Expected Output & Criteria
Departmental payroll utilization percentages compared against budget caps.
Database Table Schema (PostgreSQL DDL)
PostgreSQL 16 WASMCREATE TABLE dept_budgets (
dept_id INT PRIMARY KEY,
dept_name VARCHAR(50) NOT NULL,
budget_cap NUMERIC(12, 2) NOT NULL
);
CREATE TABLE dept_employees (
emp_id INT PRIMARY KEY,
dept_id INT REFERENCES dept_budgets(dept_id),
salary NUMERIC(10, 2) NOT NULL
);Target SQL Clauses & Operators
Want more CTEs practice?
Explore the full syllabus of 16 exercises and syntax guides.