Query editor
WITH delegators_of_delegate AS (SELECT delegate, COUNT(delegator) AS delegationsFROM query_2255644GROUP BY 1)SELECTrank() OVER (ORDER BY a.newBalance DESC) AS "rank", COALESCE(b.name, d.name) AS identity, a.delegate, CAST(a.newBalance as double)/power(10,18) AS votes, CAST(a.newBalance as double)/1e18 / SUM(CAST(a.newBalance as double)/1e18) OVER(rows between unbounded preceding and unbounded following) AS votes_percentage, c.delegations, CAST(a.newBalance as double)/1e18 / c.delegations AS votes_per_delegatorsFROM (SELECT delegate, newBalance, row_number() over (partition by delegate order by evt_block_number desc, evt_index desc) AS latestFROM arbitrum_arbitrum.L2ArbitrumToken_evt_DelegateVotesChanged) aLEFT JOIN ens.reverse_latest b ON a.delegate = b.addressLEFT JOIN query_2263822 d ON a.delegate = d.delegateINNER JOIN delegators_of_delegate c ON a.delegate = c.delegateWHERE a.latest = 1AND a.delegate != 0x00000000000000000000000000000000000a4b86ORDER BY 1