with t as (
select
trunc(timestamp, 'day') "Date",
avg(price_usd) "Price (USD)"
from flow.core.fact_prices
where symbol = '{{ symbol }}'
and "Date" >= '2022-10-01'
group by "Date"
)
select "Date",
"Price (USD)",
avg("Price (USD)") over (order by "Date" rows between 6 preceding and current row) "Moving Average (7 days)",
avg("Price (USD)") over (order by "Date" rows between 29 preceding and current row) "Moving Average (1 month)"
from t
group by "Date", "Price (USD)"
order by "Date"