MLDZMNtype_fee2 copy
    Updated 2023-05-16
    -- forked from type_fee2 @ https://flipsidecrypto.xyz/edit/queries/8277e34e-48ca-45f9-970b-04f58fdf4525

    -- forked from label2 @ https://flipsidecrypto.xyz/edit/queries/8b3ddccb-53f7-484c-9027-5aeb84a88d98

    with t1 as (select
    *

    from ethereum.core.dim_labels
    )

    select
    date_trunc('day', BLOCK_TIMESTAMP) as date,
    LABEL_TYPE,
    count(distinct tx_hash) as no_txn,
    sum(TX_FEE) as total_fee,
    avg(TX_FEE) as avg_fee,
    median(TX_FEE) as median,
    sum(total_fee) over (partition by LABEL_TYPE order by date) as cumulative_fee
    from ethereum.core.fact_transactions s
    left join t1 on s.to_address=t1.ADDRESS
    where BLOCK_TIMESTAMP>=current_date-30
    and STATUS = 'SUCCESS'
    and label_type not in ('token','operator','flotsam')
    and LABEL_TYPE != 'chadmin'
    group by 1,2



    Run a query to Download Data