Windows vs. GROUP BYConcept

Concept

Keep the rows, add the context

GROUP BY collapses rows into groups. A window function computes over a partition but keeps every row: ROW_NUMBER() for latest-per-entity, LAG/LEAD for change between rows, SUM() OVER (ORDER BY …) for running totals. Reach for a window when you need an aggregate alongside each row.

0/5 answered · Enter to check