saeedmznBase Rank - Transferred volume Distribition
    Updated 2023-12-26
    with contracts as (
    select ADDRESS ,SYMBOL
    from base.core.dim_contracts
    group by 1 ,2
    ),
    prices as (
    select HOUR::date date , SYMBOL ,
    TOKEN_ADDRESS , DECIMALS,
    avg(price) price
    from base.price.ez_hourly_token_prices
    group by 1 , 2 ,3 ,4 order by 1
    ),
    wallet as (select
    FROM_ADDRESS ,
    sum ((RAW_AMOUNT/pow(10,DECIMALS))*price) volume_usd
    from base.core.fact_token_transfers t join prices p on TOKEN_ADDRESS = CONTRACT_ADDRESS
    and p.date =t.BLOCK_TIMESTAMP::date
    group by 1
    )
    select case when volume_usd <1 then 'Less Than $1'
    when volume_usd BETWEEN 1 and 5 then '$1 - $5'
    when volume_usd BETWEEN 5 and 10 then '$5 - $10'
    when volume_usd BETWEEN 10 and 20 then '$10 - $20'
    when volume_usd BETWEEN 20 and 100 then '$20 - $100'
    when volume_usd BETWEEN 100 and 500 then '$100 - $500'
    when volume_usd BETWEEN 500 and 1000 then '$500 - $1K'
    when volume_usd BETWEEN 1000 and 10000 then '$1K - $10K'
    else 'More than $10K'
    end range ,
    count (FROM_ADDRESS) num_wallets
    from wallet
    group by 1
    QueryRunArchived: QueryRun has been archived