with userstable as (
select mindate,
count (distinct address) as New_Users,
sum (new_users) over (order by mindate) as Total_Users
from (select address, min(date) as mindate from osmosis.core.fact_daily_balances where currency = 'uosmo' group by 1)
group by 1)
select date,
new_users,
total_users,
avg (balance / pow (10,decimal)) as Average_OSMO_Balance,
Average_OSMO_Balance / new_users as "Average OSMO Balance / New Users",
Average_OSMO_Balance / total_users as "Average OSMO Balance / Total Users"
from osmosis.core.fact_daily_balances t1 join userstable t2 on t1.date = t2.mindate
where currency = 'uosmo'
group by 1,2,3
order by 1