with cat as (
select
REALMS_ID,
count(distinct proposal) as proposals,
count(distinct voter) as voters
from solana.core.fact_proposal_votes
group by 1
),
grouping as (
select
REALMS_ID,
case
when proposals > 1000 then 'More than 1k'
when proposals > 100 then 'More than 100'
when proposals > 10 then 'More than 10'
when proposals > 1 then 'Up to 10'
when proposals = 1 then 'Just one'
end as Category
from cat
group by 1, 2)
select
count(*) proposals,
category
from grouping
group by 2