Cumulative_sum on a specific time period

Dose cumulative_sum support “sum of cumulations each day”?

there is our raw series data:

select value from new_add_numbers

time                 value
----                 -----
2018-11-11T03:43:35Z 100
2018-11-11T21:09:32Z 100
2018-11-12T02:05:14Z 100
2018-11-12T06:01:47Z 100

Then select cumulative_sum(value) from new_add_numbers result as:

time                 cumulative_sum
----                 --------------
2018-11-11T03:43:35Z 100
2018-11-11T21:09:32Z 200
2018-11-12T02:05:14Z 300
2018-11-12T06:01:47Z 400

How can I get cumulative sum of each day?
like:

select cumulative_sum(value, 1d) from new_add_numbers

time                 cumulative_sum
----                 --------------
2018-11-11T03:43:35Z 100
2018-11-11T21:09:32Z 200
2018-11-12T02:05:14Z 100 // sum reset to be zero on a new day
2018-11-12T06:01:47Z 200

Thanks

Hi ,

does it give the desired result when you add to your query GROUP BY time(24h) ?

Best regards

thanks to reply!

Do you mean the query “select sum(value) from new_add_numbers groups by time(24h)”? this query groups values of each 24h into a single sum and hides real time cumulations, which is not I wanted:

select sum(value) from new_add_numbers gourps by time(24h)

time                 value
----                 --------------
2018-11-11T00:00:00Z 300
2018-11-12T00:00:00Z 300

Or maybe you mean other query that combines cumulative_sum and groups by?

I think so yes… let me know if that did the trick :slight_smile: