--credit : misaghlb
select
date_trunc('month', block_timestamp::date) as date,
EVENT_TYPE,
count(distinct tx_id) as tx_count,
row_number() over (partition by date order by tx_count DESC) as r
from flow.core.fact_events
where date >= '2022-01-01'
and TX_SUCCEEDED = true
group by 1,2
qualify r <= 5