with bridge as (
select
to_address as unique_user,
min(block_timestamp) as date
from polygon.core.fact_token_transfers
where
origin_from_address = '0x0000000000000000000000000000000000000000' and
origin_to_address = '0x0000000000000000000000000000000000000000' and
from_address = '0x0000000000000000000000000000000000000000'
group by 1
),
top as (
select row_number() over (partition by origin_to_address order by block_timestamp asc) as rank, origin_to_address
from polygon.core.fact_event_logs, bridge
where origin_from_address = unique_user and block_timestamp::date > date
)(
select
project_name,
count(*) as "count"
from top join polygon.core.dim_labels l on top.origin_to_address = l.address
where
rank = 1
group by 1
order by 2 desc
)