With no frame written, rows that tie on the ORDER BY share one total
Here are the two frames for order 1 from the last step:
| Order 1's frame | Holds | Count |
|---|---|---|
running: no frame written | #1 and #2, peers on March 1 | 2 |
running_rows: ROWS, a unique key | #1 only | 1 |
That's the default frame: with ORDER BY and no frame, you get RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW.
RANGE treats rows with the same ORDER BY value as peers, and peers enter the frame together. PostgreSQL's default is the same.
running_rows steps one order at a time, because it says ROWS and sorts on a unique key. The unique key alone would do it: once no two rows tie there are no peers, and the default frame stops exactly at the current row.
Which one you want depends on the question. Revenue through the end of each day wants the peers in. The balance after each order wants ROWS and a tie-break. Don't let the default choose for you.
In the editor, write BALANCE: the running_rows idea with SUM(amount), the revenue one order at a time.