MetaLightTop 50 $TOKE Holders
    -- forked from SocioCrypto / Top 50 $BONK Holders @ https://flipsidecrypto.xyz/SocioCrypto/q/3zZo0CVyjqA0/top-50-bonk-holders

    WITH received as (
    SELECT
    tx_to as wallet,
    sum(amount) as amnt
    FROM solana.core.fact_transfers
    WHERE mint = 'AmgUMQeqW8H74trc8UkKjzZWtxBdpS496wh4GLy2mCpo'
    AND block_timestamp::date >= '2022-12-01'
    GROUP by wallet
    ),
    sent as (
    SELECT
    tx_from as wallet,
    sum(amount) as amnt
    FROM solana.core.fact_transfers
    WHERE mint = 'AmgUMQeqW8H74trc8UkKjzZWtxBdpS496wh4GLy2mCpo'
    AND block_timestamp >= '2022-12-01'
    GROUP by wallet
    )


    SELECT top 50 s.wallet, r.wallet, l.address_name, l.label,l.label_subtype,l.label_type,
    zeroifnull(r.amnt)-zeroifnull(s.amnt) as balance,
    rank()over(order by balance DESC) as rank
    FROM sent s
    FULL JOIN received r
    ON r.wallet = s.wallet
    LEFT JOIN solana.core.dim_labels l
    ON s.wallet = l.address
    ORDER BY balance DESC


    Run a query to Download Data