Eman-RazDistribution of Holders Based on the AI Balance
    Updated 2024-11-11
    with final_tab as (with tab4 as (with tab3 as (with tab1 as (select to_address, sum(amount) as input_vol
    from blast.core.ez_token_transfers
    where contract_address=lower('0x764933fbAd8f5D04Ccd088602096655c2ED9879F')
    group by 1),

    tab2 as (select from_address, sum(amount) as output_vol
    from blast.core.ez_token_transfers
    where contract_address=lower('0x764933fbAd8f5D04Ccd088602096655c2ED9879F')
    group by 1)

    select to_address as address, case
    when input_vol is null then 0 else input_vol end as input_volume, case
    when output_vol is null then 0 else output_vol end as output_volume
    from tab1 left join tab2 on tab1.to_address=tab2.from_address)

    select address, input_volume AS "Input Volume", output_volume AS "Output Volume",
    input_volume-output_volume as "Balance"
    from tab3
    ORDER BY 4 DESC),

    tab5 as (select address, ADDRESS_name
    from blast.core.dim_labels)

    select tab4.address as ADDRESS, "Balance", case
    when "Balance"<=10000 then 'Balance<=10k AI'
    when "Balance">10000 and "Balance"<=100000 then '10k<Balance<=100k AI'
    when "Balance">100000 and "Balance"<=1000000 then '100k<Balance<=1m AI'
    when "Balance">1000000 and "Balance"<=10000000 then '1m<Balance<=10m AI'
    when "Balance">10000000 and "Balance"<=100000000 then '10m<Balance<=100m AI'
    when "Balance">100000000 and "Balance"<=1000000000 then '100m<Balance<=1b AI'
    when "Balance">1000000000 then 'Balance>1b AI'
    end as "Classification"
    from tab4 left join tab5 on tab4.address=tab5.address
    WHERE "Balance">0)

    select "Classification", count(distinct address) as "Holders Count", sum("Balance") as "Total Balance"
    Auto-refreshes every 24 hours
    QueryRunArchived: QueryRun has been archived