Query editor
WITHbase AS (SELECTpc.profileId,pc.to AS minter,pc.handleFROMlens_polygon.LensHub_evt_ProfileCreated AS pcWHEREpc.handle = '{{handle}}'),owner_changes AS (SELECTt.*,RANK() OVER (ORDER BYevt_block_number DESC) AS rnk /* over ( order by evt_block_number desc t.evt_index desc) as rank */FROMlens_polygon.LensHub_evt_Transfer AS tINNER JOIN base ON base.profileId = t.tokenId),current_owner AS (SELECTbase.profileId,base.minter,base.handle,owner_changes.to AS currentownerFROMbaseLEFT JOIN owner_changes ON owner_changes.rnk = 1),recent_posts AS (SELECTprofileId,pubId,contentURI,evt_block_timeFROMlens_polygon.LensHub_evt_PostCreated AS pWHEREprofileId = (SELECTprofileIdFROMcurrent_owner)ORDER BYevt_block_time DESC),comments AS (SELECTp.profileId,p.pubId,p.evt_block_time,COUNT(c.pubId) AS comments,COUNT(DISTINCT c.profileId) AS uniqueProfilesCommentingFROMrecent_posts AS pLEFT JOIN lens_polygon.LensHub_evt_CommentCreated AS c ON c.profileIdPointed = p.profileId