with address_list as (
select
address,
address_name,
label_type,
label_subtype,
label
from terra.labels
-- where (label_type in ('dapp', 'defi', 'dex', 'layer2') or label_subtype = 'marketplace')
-- and label_subtype not in ('token_contract', 'pool')
),
small_sample as (
select
*
from terra.transactions
where block_timestamp > getdate() - interval'30 days'
and tx_from[1] is null
),
final_table as (
select
address,
address_name,
label_type,
label_subtype,
label,
tx_id,
tx_from
from address_list
left join small_sample on tx_to[0]::string = address
)
select
address,
address_name,
label_type,
label_subtype,
label,