granadohoUniswap and Sushiswap Total and Average Gas Fee
    Updated 2022-02-02
    with get_tx_id as (
    select
    tx_id,
    from_label,
    block_timestamp
    from ethereum.udm_events
    where (from_label = 'sushiswap' or from_label = 'uniswap') and date(block_timestamp) > DATEADD(month, -2, current_date)
    ), joined as (
    select
    a.tx_id,
    b.from_label,
    b.block_timestamp,
    a.gas_price,
    a.success
    from ethereum.transactions a
    inner join get_tx_id b
    on b.tx_id = a.tx_id
    ), filtered as (
    select
    *
    from (
    select
    *,
    ROW_NUMBER() OVER (PARTITION by tx_id order by block_timestamp desc) col
    from joined
    where success = 'TRUE'
    ) a
    where a.col = 1
    )


    select
    from_label,
    SUM(gas_price/POW(10,18)) as total_gas_fee,
    AVG(gas_price/POW(10,18)) as average_gas_fee
    from filtered
    Run a query to Download Data