select
date_trunc('day', hour)::date as day,
avg(price) as price_usd,
avg (price_usd) over (order by day rows between 6 preceding and current row) as ma_7
from optimism.core.fact_hourly_token_prices
where 1 = 1
and hour >= '2022-12-01'
and token_address = '0x4200000000000000000000000000000000000042'
group by day
order by day