Know the Default Frame Before You Trust a Running Total
Explain how ORDER BY changes the default window frame and why that affects running totals, LAST_VALUE, and cumulative metrics.
ORDER BY changes more than sequence. It changes visibility. Partitions answer who belongs together A partition groups peer rows, such as all invoices for one account or all orders for one store. Many developers stop there and assume every window function can always see the whole partition. Frames answer which of those rows are visible now Once you add order by, PostgreSQL defaults to a running frame from the start of the partition through the current row, plus ties. That is perfect for cumulative sums. It is not perfect for functions that are supposed to see the actual last row…
Sign up free — one personalized lesson every day, matched to your role and goals.
Already have an account? Sign in