with
news as (
select distinct node_id as new_node,
min(trunc(block_timestamp,'week')) as debut
from flow.gov.ez_staking_actions
where tx_succeeded = 'TRUE'
group by 1
)
select
trunc(block_timestamp,'week') as week,
count (distinct node_id) as active_nodes,
count(distinct new_node) as new_nodes
from flow.gov.ez_staking_actions x
join news y on trunc(x.block_timestamp,'week')=y.debut
where tx_succeeded = 'TRUE'
group by 1 order by 1 asc ;