2021年5月7日星期五

How to get total amount per previous weeks

I have this table for example:

Date amount
2021-02-16T21:06:38 10
2021-02-16T21:07:01 5
2021-02-17T01:10:12 -1
2021-02-19T12:00:00 3
2021-02-24T12:00:00 20
2021-02-25T12:00:00 -1

I want the total amount of all previous weeks, per week in postgres. So the result in this case would be:

Date amount
2021-02-15 0
2021-02-22 17
2021-03-01 36

Note: The dates are now the start of each week (Monday).

Any help would this would be greatly appreciated.

https://stackoverflow.com/questions/67443890/how-to-get-total-amount-per-previous-weeks May 08, 2021 at 11:45AM

没有评论:

发表评论