Query editor
withreferral_list as (selectrow_number() over (partition by participant order by evt_block_time desc) as seqnum,referrer,participant,evt_block_timefrom elephant_bnb.ReferralData_evt_onReferralUpdate),last_referral_list as (selectreferrer,participantfrom referral_listwhere seqnum = 1)selectrow_number() over (order by usr_amount_total_usd desc) as ranking,CONCAT('<a href="https://debank.com/profile/0', SUBSTRING(cast(participant as varchar), 2, 42), '?t=1696409060247&r=34381" target="_blank" rel="noopener noreferrer">0', SUBSTRING(cast(referrer as varchar), 2, 5), '...',SUBSTRING(cast(referrer as varchar), 39, 42), '</a>') AS wallet,participant,coalesce(usr_amount_total_usd,0) as amount,coalesce(usr_amount_bwb,0) as amount_BWB--,coalesce(usr_amount_sum,0) as amount_TRUNKfrom last_referral_listleft join query_2823557 on user = participantwhere referrer = {{referrer wallet}}