with p1 as (select date_trunc ('month', date) as monthly, project_name as token,
count (distinct osmosis.core.fact_daily_balances.address) as number_of_users
from osmosis.core.fact_daily_balances, osmosis.core.dim_labels
where currency = osmosis.core.dim_labels.address and date <= current_date -1
and currency not ilike '%pool%'
group by 1,2)
select * from (select monthly,token, number_of_users,
row_number() over (partition by monthly order by number_of_users desc ) as num
from p1)
where num <= 5