Window functions perform calculations across a set of rows related to the current row, without collapsing them like GROUP BY.
Rank products by sales
Cumulative sales over time
Compare row to previous row
Percent of total calculation
Unique sequential number
Example: ROW_NUMBER() OVER(...)...
Rank with gaps
Example: RANK() OVER(...)...
Defines window
Example: OVER(ORDER BY Sales)...
Group within window
Example: OVER(PARTITION BY Category)...
ROW_NUMBER, RANK, SUM, etc.
Define window
Optional grouping
Order within window
Include in output
See results with additional column