Query editor
WITH a AS (SELECT * FROM (-- OptimismSELECTsum(_amount) AS amount,market AS _pool,_epoch + 1 AS epoch,_bribeToken AS token,'optimism' AS Bribetoken_chainFROM penpie_optimism.PenpieBribeManager_evt_NewBribe AS aLEFT JOIN penpie_optimism.PendleVoteManagerSideChain_evt_AddPool AS bON a._pid = b._pidWHERE (a.forVePendle = false OR a.forVePendle IS NULL)GROUP BY 2, 3, 4UNION ALL-- ArbitrumSELECTsum(_amount) AS amount,market AS _pool,_epoch + 1 AS epoch,_bribeToken AS token,'arb' AS Bribetoken_chainFROM penpie_arbitrum.PenpieBribeManager_evt_NewBribe AS aLEFT JOIN penpie_arbitrum.PendleVoteManagerSideChain_evt_AddPool AS bON a._pid = b._pidWHERE (a.forVePendle = false OR a.forVePendle IS NULL) -- forVePendle condition applied hereGROUP BY 2, 3, 4UNION ALL-- EthereumSELECTsum(_amount) AS amount,market AS _pool,_epoch + 1 AS epoch,_bribeToken AS token,'eth' AS Bribetoken_chainFROM penpie_ethereum.PenpieBribeManager_evt_NewBribe AS aLEFT JOIN penpie_ethereum.PendleVoteManagerMainChain_evt_AddPool AS bON a._pid = b._pidWHERE (a.forVePendle = false OR a.forVePendle IS NULL) -- forVePendle condition applied hereGROUP BY 2, 3, 4UNION ALL-- BNBSELECTsum(_amount) AS amount,market AS _pool,_epoch + 1 AS epoch,_bribeToken AS token,'bnb' AS Bribetoken_chainFROM penpie_bnb.PenpieBribeManager_evt_NewBribe AS aLEFT JOIN penpie_bnb.PendleVoteManagerSideChain_evt_AddPool AS bON a._pid = b._pidWHERE (a.forVePendle = false OR a.forVePendle IS NULL) -- forVePendle condition applied hereGROUP BY 2, 3, 4