Использование совокупной суммы в Postgres:
select
dt, user_id, amount_actions,
to_char(dt, 'WWYYYY') wk,
sum(amount_actions)
over
(partition by user_id, to_char(dt, 'WWYYYY')
order by user_id, dt) rolling_sum_7_days
from
tbl
order by user_id, dt;
Раздел: user_id
+ WeekYear
to_char (dt, 'WWYYYY')
dt | user_id | amount_actions | wk | rolling_sum_7_days
:--------- | ------: | -------------: | :----- | -----------------:
2018-12-01 | 1 | 2 | 482018 | 2
2018-12-02 | 1 | 1 | 482018 | 3
2018-12-10 | 1 | 1 | 502018 | 1
2018-12-01 | 2 | 2 | 482018 | 2
2018-12-02 | 2 | 1 | 482018 | 3
2018-12-10 | 3 | 1 | 502018 | 1
дБ <> скрипка здесь