Query editor
WITH profile AS (SELECTprofile.fid,profile.fname,profile.display_name,profile.avatar_url,ROW_NUMBER() OVER (PARTITION BY profile.fid ORDER BY LENGTH(profile.verified_addresses) DESC) AS rnFROM dune.neynar.dataset_farcaster_profile_with_addresses AS profile), tips AS (SELECTTRY_CAST(REGEXP_EXTRACT(REGEXP_EXTRACT(UPPER(casts.text), '([0-9]+) \$DEGEN'), '[0-9]+') AS DOUBLE) AS tip_amount,casts.text AS texts,DATE_TRUNC('day', casts.timestamp - INTERVAL '7' HOUR - INTERVAL '35' MINUTE) AS event_day,casts.parent_fid AS recipient_fid,casts.fid AS donor_fidFROM dune.neynar.dataset_farcaster_casts AS castsWHERENOT casts.fid IN (217745, 234434, 244128)AND REGEXP_LIKE(UPPER(casts.text), '[0-9]+ \$DEGEN')AND NOT casts.parent_hash IS NULLAND casts.deleted_at IS NULLAND casts.timestamp > TO_DATE('20240330', 'yyyymmdd')AND casts.parent_fid <> casts.fid), tips2 AS (SELECTp.fname,t.*FROM tips AS tINNER JOIN profile AS pON t.recipient_fid = p.fidWHEREp.rn = 1 /* Assuming you only want profiles with rn = 1; add this line if profiles need to be unique or top ranked. */-- AND t.donor_fid IN (400377)AND t.recipient_fid IN (400377)-- AND t.event_day = CURRENT_DATE - INTERVAL '5' DAY)SELECTp2.display_name AS tip_for,t2.*FROM tips2 AS t2INNER JOIN profile AS p2ON t2.donor_fid = p2.fidWHEREp2.rn = 1AND t2.tip_amount >= 1000ORDER BY t2.donor_fid