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