SocioCryptoTop 100 users in terms of tx_fee paid
    Updated 2023-04-20
    -- forked from Top 100 users in terms of n_txns @ https://flipsidecrypto.xyz/edit/queries/d42f1153-a9b9-43a6-8cea-8e210cfdd1d6

    -- forked from Top users in terms of n_txns @ https://flipsidecrypto.xyz/edit/queries/70ca453f-3222-4918-afbd-2fa1b13e0e38

    with first_received as (
    SELECT *
    from(
    SELECT to_address as user,
    project_name as CEX,
    tx_hash,
    rank()over(partition by to_address order by block_timestamp) as rank
    FROM
    (
    SELECT
    project_name,
    to_address,
    tx_hash,
    block_timestamp
    FROM avalanche.core.ez_token_transfers a
    LEFT JOIN avalanche.core.dim_labels b
    on a.from_address = b.address
    WHERE b.label_type = 'cex'
    UNION
    SELECT
    project_name,
    eth_to_address,
    tx_hash,
    block_timestamp
    FROM avalanche.core.ez_avax_transfers a
    LEFT JOIN avalanche.core.dim_labels b
    on a.eth_from_address = b.address
    WHERE b.label_type = 'cex'
    )
    )
    where rank = 1
    ),
    Run a query to Download Data