h4wkBonk Holders Distribution
    Updated 2024-09-20
    -- forked from BonkSOL Holders Distribution @ https://flipsidecrypto.xyz/edit/queries/4fe35c0b-502d-4060-8e68-44b2b745218f

    with price as (
    select hour::date as price_date,
    symbol,
    avg(price) as price
    from solana.price.ez_prices_hourly
    where token_address = 'DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263'
    group by 1,2
    qualify row_number() over (order by price_date desc) = 1
    )
    , base as (
    select owner,
    balance,
    balance * price as balance_usd
    from solana.core.fact_token_balances join price
    where mint = 'DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263'
    qualify row_number() over (partition by owner order by block_timestamp desc) = 1
    )


    select
    case
    when balance_usd < 10 then 'Hold < $10'
    when balance_usd < 100 then 'Hold < $100'
    when balance_usd < 1000 then 'Hold < $1000'
    when balance_usd < 10000 then 'Hold < $10k'
    else 'Hold > $10k' end as type,
    -- https://count.co/sql-resources/snowflake/histograms
    count(owner) as user_count,
    -- floor(balance_usd / 10) * 10 as hold_amount,
    -- floor(balance / 10) * 10 + 10 as bin_end,
    -- concat(
    -- '$'||cast(floor(amount_usd / 90) * 90 as STRING),
    -- ' - ',
    -- '$'||cast(floor(amount_usd / 90) * 90 + 90 as STRING)
    Last run: about 2 months ago
    TYPE
    USER_COUNT
    Total
    1
    Hold < $10677191677191
    2
    Hold < $100121333798524
    3
    Hold < $100046455844979
    4
    Hold < $10k13876858855
    5
    Hold > $10k3726862581
    5
    147B
    289s