with a as
(select
date_trunc('hour',block_timestamp) as hour,
sum(deposit_amount_usd) as "hourly deposits",
avg("hourly deposits") over (order by hour rows between 6 preceding and current row) as "6 hour average"
from anchor.deposits
where block_timestamp >= getdate() - interval '30 days'
group by 1
order by 1)
select
sum("hourly deposits") as total_deposits
from a