adriaparcerisasosmosis balances usd
    Updated 2023-01-16
    WITH
    price as (
    SELECT
    trunc(recorded_hour,'day') as days,
    avg(price) as price_usd
    from osmosis.core.ez_prices where symbol='STARS' and recorded_hour>='2022-03-20'
    group by 1
    order by 1 asc
    ),
    balance as (
    SELECT
    date,
    balance,
    address
    from osmosis.core.fact_daily_balances
    where date>='2022-03-20' and currency='ibc/987C17B11ABC2B20019178ACE62929FE9840202CE79498E29FE8E5CB02B7C0A4'
    )
    SELECT
    date,
    case when balance*price_usd >1000000 then 'a. >1M USD'
    when balance*price_usd between 500000 and 1000000 then 'b. 500m-1M USD'
    when balance*price_usd between 100000 and 500000 then 'c. 100m-500m USD'
    when balance*price_usd between 50000 and 100000 then 'd. 50m-100m USD'
    when balance*price_usd between 10000 and 50000 then 'e. 10m-50m USD'
    when balance*price_usd between 1000 and 10000 then 'f. 1m-10m USD'
    else 'g. <1m USD' end as balance_usd,
    count(distinct address) as holders
    from balance b
    join price p on b.date=p.days
    group by 1,2 order by 1 asc,2

    Run a query to Download Data