How can we project departmental average compensation across each record?
AVG() OVER (PARTITION BY ...) calculates group benchmarks while preserving all underlying records.
Departmental pay benchmarking, outlier detection, variance modeling.
SELECT
department_id,
name,
salary,
AVG(salary) OVER (
PARTITION BY department_id
) AS department_average
FROM employees;Practice typing production-grade SQL code for Partitioned Average.