Popex404Top 10 Wallets by BTC.B Balance
    Updated 2023-03-14
    -- forked from c597a5dc-0bc7-4065-a786-8d516cd71f8d Forked my Top projects Query to limit the number of Wallets

    With cte as (
    SELECT
    to_address as BTCB_WALLET,
    raw_amount/power(10, 8) as Volume
    FROM avalanche.core.fact_token_transfers
    WHERE contract_address = lower('0x152b9d0FdC40C096757F570A51E494bd4b943E50')
    UNION ALL
    Select
    from_address as BTCB_WALLET,
    -(raw_amount/power(10,8)) as Volume
    FROM avalanche.core.fact_token_transfers
    WHERE contract_address = lower('0x152b9d0FdC40C096757F570A51E494bd4b943E50')
    )

    select coalesce(Address_name,substr(BTCB_WALLET,0,5)||'...'||substr(BTCB_WALLET,-3,3)) as "Wallet Name",
    BTCB_Wallet as "Address",
    sum(Volume) as "Balance"
    from cte LEFT JOIN avalanche.core.dim_labels on address=BTCB_WALLET
    group by 1,2
    having "Balance">0
    order by 3 desc
    limit 10


    Run a query to Download Data