How can we display each employee alongside their department average salary?
AVG() OVER (PARTITION BY department_id) attaches the department average to every row without GROUP BY.
Comparing individual performance/salary against group benchmarks without reducing row count.
SELECT
name,
department_id,
salary,
AVG(salary) OVER (
PARTITION BY department_id
) AS department_average
FROM employees;Practice typing production-grade SQL code for Department Average Window.