MoeCopy of maingas4
    Updated 2023-02-25
    select * from
    (with
    p as (select hour::date as day,
    avg (price) as price
    from ethereum.core.fact_hourly_token_prices
    where symbol = 'MATIC'
    group by day)
    select
    date_trunc('day', block_timestamp)::date as date ,
    price,
    count(distinct BLOCK_NUMBER) as block_count,
    sum (tx_fee*price) as total_fee_usd,
    avg (tx_fee*price) as avg_fee_usd,
    avg (tx_fee) as avg_fee,
    total_fee_usd/block_count as fee_usd_per_block,
    avg(avg_fee)over( order by date rows between 7 preceding and current row) as mov_avg_7,
    avg(avg_fee)over( order by date rows between 100 preceding and current row) as mov_avg_100
    from polygon.core.fact_transactions join p on block_timestamp::Date = day
    group by 1,2)
    where date >= CURRENT_DATE - 60

    Run a query to Download Data