Cumulative cash flows

Question

Suppose you're given the following table showing daily cash flows for a business:

Table: cash_flows

day cash_flow
1 1000
2 -300
3 1200
4 1500
5 -2000
6 700
7 650
8 900

Given the above table, write a SQL query to return the cumulative cash flow by day for the company.

For example, by day 3 your table should show 1900 (1000-300+1200) as the value.

You can view/query this table in an interactive SQL fiddle here.

Solution

Access restricted

Subscribe to premium account to see the solution.

Get premium now