Query editor
WITH subject_sums AS (SELECTsubject,SUM(subjectEthAmount) AS total_subjectEthAmountFROM friendtech_base.FriendtechSharesV1_evt_TradeGROUP BYsubject), ft_profile AS (SELECTaddress,twitterusername,twitternameFROM dune.hildobby.dataset_friendtech_profiles)SELECTROW_NUMBER() OVER (ORDER BY subject_sums.total_subjectEthAmount DESC) AS ranking,subject_sums.subject as address,CASE WHEN ft_profile.address IS NULL THEN '-' ELSE ft_profile.twitterusername END AS twitterusername,CASE WHEN ft_profile.address IS NULL THEN '-' ELSE ft_profile.twittername END AS twittername,subject_sums.total_subjectEthAmount / 1e18 AS fees_earnFROM subject_sumsLEFT JOIN ft_profileON subject_sums.subject = ft_profile.addressORDER BYfees_earn DESC