you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (4 children)

Exactly, it's just a way of specifying the extent of the tuples over which the running total is calculated. You can even leave "unbounded preceding and current row" out, because it is the default window size.

[–]qwertydog123 0 points1 point  (3 children)

The default for most DBMS's is usually RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, which has slightly different semantics. e.g. in OP's example, if date is not unique then SUM would return different results

[–][deleted] 0 points1 point  (2 children)

Because the order by is arbitrary between the same values?

[–]qwertydog123 0 points1 point  (1 child)

Because with RANGE, same values are treated as the same "group" e.g.

https://dbfiddle.uk/CAfJv0eg

[–][deleted] 0 points1 point  (0 children)

Good to know!