MLDZMNSNE2
    Updated 2023-02-26
    with tb1 as (select
    distinct ORIGIN_FROM_ADDRESS as wallets
    from ethereum.core.fact_event_logs
    where ORIGIN_TO_ADDRESS='0x881d40237659c251811cec9c364ef91dc08d300c'
    and EVENT_NAME='Swap'),

    tb2 as (select
    USER_ADDRESS,
    CURRENT_BAL as blnce
    from ethereum.core.ez_current_balances
    where USER_ADDRESS in (select wallets from tb1)
    and CONTRACT_ADDRESS= lower('0x85F17Cf997934a597031b2E18a9aB6ebD4B9f6a4')

    )

    select
    count(distinct USER_ADDRESS) as total_holders,
    sum(blnce) as total_near,
    avg(blnce) as avg_near,
    median(blnce) as median_near
    from tb2
    Run a query to Download Data