A window function computes a value per row while looking at a
group of related rows — without collapsing them the way GROUP BY
does.
SQL
SELECT
order_date,
amount,
SUM(amount) OVER (ORDER BY order_date) AS running_total
FROM orders;
Every row keeps its identity; the window (OVER …) decides which
rows each calculation may see.
Tip
If you catch yourself joining a table to an aggregated copy of itself, you almost always want a window function instead.