Query editor
-- This query used incompatible data types from Dune SQL alpha and may need to be updated.-- More details can be found on https://dune.com/docs/query/dunesql-changes/with profile_created as (select distinct p.handle,p.profileId as profile_id,p.evt_tx_hash,p.evt_block_time,first_value(t."to") over (partition by t.tokenId order by t.evt_block_time desc) as owner -- last transfer to is ownerfrom lens_polygon.LensHub_evt_ProfileCreated pinner join lens_polygon.LensHub_evt_Transfer t on p.profileId = t.tokenId),multiple_profiles_owner as (select owner,count(profile_id) as own_profile_countfrom profile_createdgroup by 1having count(profile_id) > 1),top_profile_holders as (select owner,own_profile_countfrom multiple_profiles_ownerorder by own_profile_count desclimit 100)select owner,own_profile_count,sum(own_profile_count) over () as total_profiles_count,avg(own_profile_count) over () as average_profiles_count,'<a href=https://polygonscan.com/address/' || owner || ' target=_blank>PolygonScan</a>' as linkfrom top_profile_holdersorder by own_profile_count desc