Query editor
WITHgetAllRolls as (SELECTchain,evt_block_time,evt_tx_hash,contract_address,token,id,seats,winners,betAmount,payoutFROMbetswirl_multichain.russianroulette_v2_evt_roll),getGamesResults AS (selectevt_block_time,chain,evt_tx_hash,contract_address,token,id,player,COUNT(*) as number_of_bets,SUM(CASEWHEN winner = player THEN 1ELSE 0END) as number_of_winsfrombetswirl_multichain.russianroulette_v2_evt_rollCROSS JOIN UNNEST (seats, winners) as t (player, winner)GROUP BY1,2,3,4,5,6,7)SELECTCASEWHEN chain = 'avalanche_c' THEN 'Avalanche'WHEN chain = 'polygon' THEN 'Polygon'WHEN chain = 'arbitrum' THEN 'Arbitrum'WHEN chain = 'base' THEN 'Base'WHEN chain = 'bnb' THEN 'BNB Chain'END as blockchain,evt_block_time,game,player,token,amount,payout,evt_tx_hashFROM