Problem Statement
In a window definition, what do PARTITION BY and ORDER BY control?
Explanation
PARTITION BY splits the result set into logical groups. The function runs separately within each partition. ORDER BY sets the sequence inside each partition so the function can compute running or ranked results.
Leaving PARTITION BY out means the entire result is a single partition. Leaving ORDER BY out makes ranking undefined and turns many analytics into simple per-partition aggregates.
Code Solution
SolutionRead Only
SUM(amount) OVER (PARTITION BY customer_id ORDER BY sale_ts)
