e.g. in BigQuery,
select
date,
cnt_booking,
sum(cnt_booking) over (order by unix_date(date) range between 06 preceding and current row) as cnt_booking_last_07_days,
sum(cnt_booking) over (order by unix_date(date) range between 27 preceding and current row) as cnt_booking_last_28_days,
from (
select
date,
count(1) as cnt_booking,
from
booking
group by
date
)
order by
date
Our team usually tracking metrics in rolling period (7 days, 28 days),
To neutralize effects of seasonality.
So it would be great, if we can set rolling period in running total.