select
date_trunc('day', hour) as day,
avg(price) as price_usd,
avg (price_usd) over (order by day rows between 6 preceding and current row) as moving_average_1_week
from ethereum.core.fact_hourly_token_prices
where symbol = 'IDEX'
and day between date('2023-01-01') - interval '2 weeks' and date('2023-01-01') + interval '2 weeks'
group by day
order by day