Before Window Functions, calculating a running total required a complex self-join. Now, it’s a one-liner.
SELECT OrderDate, Amount,
SUM(Amount) OVER (ORDER BY OrderDate) as RunningTotal
FROM Sales;
Why? It’s significantly faster because the database only scans the table once (O(N) vs O(N^2)).
