Window function
Applies to: sql
A window function computes across a set of rows related to the current row without collapsing them (unlike
GROUP BY). With OVER (PARTITION BY ... ORDER BY ...) you get running totals, rankings, and moving averages
while keeping every row.
SELECT day, sales,
SUM(sales) OVER (ORDER BY day) AS running_total
FROM daily;
See also: group-by, aggregate-function