Query editor
with t as (select evt_tx_hash,evt_block_time,playerOneOwner,gladiatorOne,playerTwoOwner,gladiatorTwofrom cyberstadium_polygon.CSCombat_evt_BattleStartedwhere contract_address = 0x3eBcEE62b21cd91347280863D2d3bCeb5DB79a01-- union all-- select evt_tx_hash,evt_block_time,playerOneOwner,gladiatorOne,playerTwoOwner,gladiatorTwo-- from cyberstadium_polygon.CSCombat_evt_BattleStarted-- where contract_address = 0x785aeb35616CFC335A656a420009cD97872169B6),w as(select tx_hash,block_time,bytearray_to_uint256(topic3) as loser from polygon.logswhere contract_address = 0x8e108e2388edad2d2b3c1ecb1582ec03c9eede0band topic0 = 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef),cal as (select t.evt_tx_hash, t.evt_block_time,playerOneOwner as go1,gladiatorOne as gn1,playerTwoOwner as go2,gladiatorTwo as gn2,loser from tleft join won t.evt_tx_hash = w.tx_hash),stad as (select distinct gn1 as "Gladiator ID", count(gn1) as sec from calwhere gn1 <= cast(100000 as uint256)and loser is not nullgroup by 1union allselect distinct gn2 as "Gladiator ID", count(gn2) as sec from calwhere gn2 <= cast(100000 as uint256)and loser is not nullgroup by 1order by 2 desc),x as (select distinct("Gladiator ID"), sec,case when loser = "Gladiator ID" then 'Dead' else 'Alive' end as "Status" from stadleft join cyberstadium_polygon.CSCombat_evt_BattleCompleteon "Gladiator ID" = loser)select distinct("Gladiator ID"), sum(sec) as "Stadium Enter Count"-- ,"Status"from xgroup by 1-- ,3order by 2 desc