with balance as ( select date,address, avg(balance/pow(10,decimal)) as average_osmo
from osmosis.core.fact_daily_balances
where CURRENCY ilike '%osmo%'
and DATE::date >= '2022-01-01'
group by 1,2)
,
average as ( select date, avg(average_osmo) as average
from balance
group by 1)
,
users_growth as ( select date, count(DISTINCT(address)) as total, sum(total) over (order by date asc) as cum_user
from osmosis.core.fact_daily_balances
where CURRENCY ilike '%osmo%'
and DATE::date >= '2022-01-01'
group by 1)
select a.date, average , total, cum_user
from average a left outer join users_growth b on a.date = b.date