Madiusers
    Updated 2023-12-10
    with
    contracts as (
    select
    ORIGIN_FROM_ADDRESS as wallet,
    count (DISTINCT contract_address) as count_contracts
    from ethereum.core.ez_token_transfers
    group by 1),

    maxbalancedate as (
    select
    USER_ADDRESS as wallet,
    max(block_timestamp) as maxdate
    from ethereum.core.fact_eth_balances
    group by 1
    ),

    balancewallet as
    (select
    USER_ADDRESS, sum(USD_VALUE_NOW) as usd_balance
    from ethereum.core.ez_current_balances a join maxbalancedate b on USER_ADDRESS = wallet
    group by 1
    )

    select USER_ADDRESS as wallet, count_contracts, usd_balance
    from balancewallet join contracts on USER_ADDRESS = wallet
    order by usd_balance desc, count_contracts desc
    Run a query to Download Data