Query editor
WITH getAllVotes as (SELECT a.evt_block_time,number_of_pool,pool_address,pool_address_2,pool_address_3,voter,CASE WHEN b.evt_index IS NOT NULL THEN 'positive' else 'negative' END as weight_impact,CAST(CAST(weight AS UINT256) AS DOUBLE)/POW(10,18) AS weight,a.evt_tx_hash,a.evt_index,rnFROM (select evt_block_time,bytearray_substring(data,69,32) as number_of_pool,bytearray_substring(data,113,20) as pool_address,bytearray_substring(data,145,20) as pool_address_2,bytearray_substring(data,177,20) as pool_address_3,voter,weight,evt_tx_hash,evt_index,ROW_NUMBER() OVER (PARTITION BY evt_tx_hash ORDER BY evt_index) as rnFROM mahadao_v2_ethereum.BaseV2Voter_evt_VotedINNER JOIN ethereum.transactions ON evt_tx_hash = hash) a LEFT JOIN mahadao_v2_ethereum.BaseV2Bribes_evt_Deposit b ON a.evt_block_time = b.evt_block_time AND a.evt_tx_hash = b.evt_tx_hash AND a.evt_index - 1 = b.evt_index),getVotesBreakdown as (select evt_block_time,voter,pool_address as pool,weight_impact,weight,evt_tx_hash,evt_index from getAllVotesWHERE number_of_pool = 0x0000000000000000000000000000000000000000000000000000000000000001 -- gets all vote transactions for 1 pool-- UNION ALL-- select evt_block_time,voter,pool_address,weight,evt_tx_hash,evt_index from getAllVotes-- WHERE number_of_pool = 0x0000000000000000000000000000000000000000000000000000000000000002 -- gets all vote transactions for 2 pool 1st pool-- AND rn = 1UNION ALLselect evt_block_time,voter,CASE WHEN rn = 1 THEN pool_address ELSE pool_address_2 END as pool_address,weight_impact,weight,evt_tx_hash,evt_indexfrom getAllVotesWHERE number_of_pool = 0x0000000000000000000000000000000000000000000000000000000000000002 -- gets all vote transactions for 2 poolAND rn IN (1,2)UNION ALLselect evt_block_time,voter,CASE WHEN rn = 1 THEN pool_addressWHEN rn = 2 THEN pool_address_2ELSE pool_address_3END as pool_address,weight_impact,weight,evt_tx_hash,evt_indexfrom getAllVotesWHERE number_of_pool = 0x0000000000000000000000000000000000000000000000000000000000000003 -- gets all vote transactions for 3 pool