with min1 as (select address,balance / pow (10,decimal) as balance
from osmosis.core.fact_daily_balances
where currency = 'uosmo'
and date = (select max(date) from osmosis.core.fact_daily_balances))
select case
when balance < 50 then '< 50 OSMO'
when balance BETWEEN 50 and 100 then '50 ~ 100 OSMO'
when balance BETWEEN 100 and 500 then '100 ~ 500 OSMO'
when balance BETWEEN 500 and 1000 then '100 ~ 500 OSMO'
else '> 1000 OSMO' end as type,count(distinct address) as wallets
from min1
group by 1