WITH eth_Price AS
(
SELECT
hour::date as date,
AVG(price) as price
FROM
ethereum.core.fact_hourly_token_prices
WHERE
TOKEN_ADDRESS is NULL
AND
SYMBOL is NULL
AND
HOUR::date >= CURRENT_DATE - 50
GROUP BY
1
),
main AS
(
SELECT
date,
'moving_Avg_20' as timeline,
AVG(SUM(price)) over (order by
date rows between 20 PRECEDING
and current row) as moving_Avg
FROM
eth_Price
WHERE
date >= CURRENT_DATE - 20
GROUP BY
1
UNION ALL
SELECT
date,