HosseinUntitled Query
    Updated 2022-11-11
    select * from (
    select
    'FTT' as token,
    date_trunc('day', hour)::date as day,
    iff(day < '2022-11-06', 'Before Crash', 'After Crash') as type,
    avg(price) as price_avg,
    min(price) as price_min,
    max(price) as price_max,
    avg (price_avg) over (order by day rows between 6 preceding and current row) as moving_avg_7_days,
    avg (price_avg) over (order by day rows between 29 preceding and current row) as moving_avg_30_days
    from ethereum.core.fact_hourly_token_prices
    where day >= '2022-10-01'
    and token_address = '0x50d1c9771902476076ecfc8b2a83ad6b9355a4c9'
    group by day, token

    union


    select
    'ETH' as token,
    date_trunc('day', hour)::date as day,
    iff(day < '2022-11-06', 'Before Crash', 'After Crash') as type,
    avg(price) as price_avg,
    min(price) as price_min,
    max(price) as price_max,
    avg (price_avg) over (order by day rows between 6 preceding and current row) as moving_avg_7_days,
    avg (price_avg) over (order by day rows between 29 preceding and current row) as moving_avg_30_days
    from ethereum.core.fact_hourly_token_prices
    where day >= '2022-10-01'
    and symbol = 'WETH'
    group by day, token
    ) order by day
    Run a query to Download Data