with new_accounts as ( select
FROM_ADDRESS ,
min (BLOCK_TIMESTAMP) min_date
from base.core.fact_transactions
group by 1 having min_date >= current_date - 30
),
labels as (
select ADDRESS ,
LABEL_TYPE,
PROJECT_NAME
from base.core.dim_labels
)
select
LABEL_TYPE ,
count (DISTINCT tx_hash) num_transactions ,
count (DISTINCT FROM_ADDRESS ) num_accounts
from base.core.fact_transactions join new_accounts
using ( FROM_ADDRESS)
join labels on (TO_ADDRESS = ADDRESS )
where STATUS = 'SUCCESS'
group by 1