with table_1 as (select min(block_timestamp) as initial,
origin_from_address as bridger
from ethereum.core.fact_event_logs
where tx_status = 'SUCCESS'
and origin_to_address = lower('0xa0c68C638235ee32657E8f720a23cec1bfc77c77')
group by 2),
table_2 as (select min(block_timestamp) as poly_initial,
bridger
from table_1 g
join polygon.core.fact_event_logs h on g.bridger = h.origin_from_address
where tx_status = 'SUCCESS'
group by 2),
table_3 as (select poly_initial,
g.bridger
from table_2 g
join table_1 h on g.bridger = h.bridger
where poly_initial > initial),
table_4 as (select *
from polygon.core.fact_event_logs g
join table_3 h on g.origin_from_address = h.bridger and g.block_timestamp = h.poly_initial
where tx_status = 'SUCCESS')
select label_subtype,
count(distinct(origin_from_address)) as n_wallet,
row_number () over (order by n_wallet desc) as count1
from polygon.core.dim_labels g
join table_4 h on g.address = h.origin_to_address
where tx_status = 'SUCCESS'
and not label_subtype = 'bridge'
group by 1
order by 2 desc
limit 10