with bot_s as (
select date_trunc('minute',block_timestamp) as min,
trader,
count(tx_id) as used
from terra.swaps
where block_timestamp::date >= current_date - 30
group by 1, 2
having used >= 20
),
bots as (
select
'BOTS' as user_type,
count(tx_id) as swaps
from terra.swaps
where block_timestamp::date > current_date - 30
and trader in (select distinct trader from bot_s)
group by 1
),
ord_users as (
select
'Average users' as user_type,
count(tx_id) as swaps
from terra.swaps
where block_timestamp::date > current_date - 30
and trader not in (select distinct trader from bot_s)
group by 1
)
select * from bots
union all
select * from ord_users