select
project_name,
count(distinct(a.address)) total_holders,
sum(balance/ power(10,6)) total_balance,
avg(balance/ power(10,6)) avg_balance,
median(balance/ power(10,6)) median_balance
from osmosis.core.dim_labels b
join osmosis.core.fact_daily_balances a
where 1 = 1
and a.currency = b.address
and date = '2022-10-21'
and currency not like 'gamm/pool/%'
and balance_type = 'liquid'
group by project_name
order by total_holders desc
limit 10