Introduction to Window Functions
What are Window Functions?
Window functions perform calculations across a set of rows related to the current row — without collapsing them into a single result like GROUP BY does.
SELECT name, department, salary,
AVG(salary) OVER (PARTITION BY department) AS dept_avg
FROM employees;
The key difference: each row keeps its own identity in the result set.