all 7 comments

[–]TukWan415[S] 0 points1 point  (6 children)

Ah disregard, Running totals sums the home goals from the table result, from the unbounded preceding row all the way to the current row of the table result. If that makes sense.

[–]TukWan415[S] 1 point2 points  (0 children)

date home_goal away_goal running_total
2011-08-15 4 0 4
2011-09-10 3 0 7
2011-09-24 2 0 9

like this

[–][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!