Window functions: SQL patterns and examples

Running totals, rankings, moving averages and row-to-row comparisons. Window functions calculate across related rows without collapsing them, which is why they replace most self-joins.