with tab1 as (
select
trader as trader1,
count(*)
from terra.swaps
where block_timestamp > current_date - 112
group by 1
order by 2 DESC
limit 72 )
select
swap_pair,
date_trunc('day', block_timestamp) as date1,
count(*) as BOT
from terra.swaps
where trader in (select trader1 from tab1) and block_timestamp > current_date - 30 and swap_pair is not null
group by 1,2