SQLAdvanced#windows

What is a window function?

A function computed over a set of rows related to the current row (its window) without collapsing the result set, declared with OVER (PARTITION BY ... ORDER BY ...).

Example
SELECT name, dept_id, salary,
       AVG(salary) OVER (PARTITION BY dept_id) AS dept_avg
FROM employees;

Related Questions

1
SQLAdvanced#windows

Difference between ROW_NUMBER, RANK and DENSE_RANK?

Open
2
SQLAdvanced#windows

What do LAG and LEAD do?

Open
3
SQLIntermediate#queries#windows

How do you find the Nth highest salary?

Open