I'm working on a query that produces a running sum of the size column grouped by created
and type
, and also considers the deleted
date. So I don't mean just a sum for that date, but a running sum. If I put an apple in the bucket on Monday (total for Monday = 1). If I put another apple in on Tuesday (total for Tuesday = 2), ...
I'm just stumped on how to start.
Here's some sample data:
[id,type, size, created, deleted] 1,A, 2, 2014-08-05, 2014-08-06 2,A, 3, 2014-08-05, 3,A, 5, 2014-08-06, 4,A, 4, 2014-08-06, 5,B, 2, 2014-08-06, 2014-08-06 6,B, 4, 2014-08-07, 2014-08-07 7,C, 6, 2014-08-07, 2014-08-07 8,C, 4, 2014-08-07, 9,D, 3, 2014-08-07, 10,E, 5, 2014-08-07, 11,C, 6, 2014-08-07,
Results should look like this:
[Date, Type, Sum] 2014-08-05,A,5 (sum of IDs 1,2) 2014-08-06,A,14 (sum of IDs 1,2,3,4) 2014-08-06,B,2 2014-08-07,A,11 (sum of IDs 2,3,4: Notice that ID 1 is not included because it was deleted 2014-08-06) 2014-08-07,B,6 (sum of IDs 5,6) 2014-08-07,C,16 (sum of IDs 7,8,11) etc...