Query editor
WITH base_delegation_data AS (SELECTblock_date,delegate,previousVotes / POW(10,18) as previous_votes,newVotes / POW(10,18) as new_votes,newVotes / POW(10,18) - previousVotes / POW(10,18) as votes_change,tx_from,tx_hashFROM TABLE(DECODE_EVM_EVENT(abi => '{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"indexed":false,"internalType":"uint256","name":"previousVotes","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newVotes","type":"uint256"}],"name":"DelegateVotesChanged","type":"event"}',input => TABLE(SELECT *FROM scroll.logsWHERE contract_address IN (0xd29687c813d741e2f938f4ac377128810e217b1b)AND topic0 = 0xdec2bacdd2f05b59de34da9b523dff8be42e5e38e818c82fdb0bae774387a724),null_on_error => FALSE))),ranked_votes AS (SELECTdelegate,new_votes as voting_power,block_date as last_updated,ROW_NUMBER() OVER (PARTITION BY delegate ORDER BY block_date DESC, tx_hash DESC) as rnFROM base_delegation_data)SELECTCOALESCE(e.name, 'NoENSname') as delegate_name,r.delegate as address,r.voting_power,r.last_updatedFROM ranked_votes rLEFT JOIN labels.ens e ON r.delegate = e.addressWHERE rn = 1and voting_power >= 1ORDER BY r.voting_power DESC;