MLDZMNcomp2
    Updated 2023-03-29
    with tb1 as (select
    HOUR::date as day,
    avg(PRICE) as price_token
    from ethereum.core.fact_hourly_token_prices where SYMBOL='WETH'
    group by 1),


    tb2 as (select
    HOUR::date as day,
    avg(PRICE) as price_token
    from ethereum.core.fact_hourly_token_prices where SYMBOL='MATIC'
    group by 1),

    tb3 as (select
    HOUR::date as day,
    avg(PRICE) as price_token
    from ethereum.core.fact_hourly_token_prices where SYMBOL='WAVAX'
    group by 1)

    select
    date_trunc('day',BLOCK_TIMESTAMP) as date,
    'Polygon' as chain,
    count(distinct tx_hash) as no_txn,
    count(distinct FROM_ADDRESS) as no_users,
    sum(TX_FEE*price_token) as paid_fee,
    avg(tx_fee*price_token) as avg_fee,
    median(tx_fee*price_token) as median_fee,
    min(TX_FEE*price_token) as min_usd,
    max(TX_FEE*price_token) as max_usd

    from Polygon.core.fact_transactions s left join tb2 b on s.BLOCK_TIMESTAMP::date=b.day
    where STATUS='SUCCESS' and block_timestamp>=current_date- {{Time_period}}
    group by 1
    Run a query to Download Data