select case when PROJECT_NAME ilike '%astro%' then 'Astroport' else PROJECT_NAME end as projects,
case when block_timestamp >= '2023-01-14' then 'After Announcement' else 'Before Announcement' end as timeframe,
count(DISTINCT tx_id) as txs,
rank() over (partition by timeframe order by txs desc) as r
from terra.core.dim_address_labels
join terra.core.fact_transactions
on address=tx:body:messages[0]:contract
where tx_succeeded= TRUE
and block_timestamp >= '2023-01-07' and block_timestamp<= '2023-01-21'
group by 1,2
qualify r<=5