Query editor
WITH usdtbets AS (SELECTazuro_polygon.PrematchCore_evt_NewBet.*,margin / 1e12 as coef_marginFROMazuro_polygon.PrematchCore_evt_NewBetLEFT JOIN azuro_polygon.PrematchCore_evt_NewBetMargin ON azuro_polygon.PrematchCore_evt_NewBet.evt_tx_hash = azuro_polygon.PrematchCore_evt_NewBetMargin.evt_tx_hashAND azuro_polygon.PrematchCore_evt_NewBet.tokenId = azuro_polygon.PrematchCore_evt_NewBetMargin.betId),usdtbetsfbs AS (SELECTusdtbets.*,CASEWHEN fbs.azuroBetId IS NULL THEN falseELSE trueEND AS is_freebetFROMusdtbetsLEFT JOIN query_3565136 AS fbs ON usdtbets.evt_tx_hash = fbs.evt_tx_hash),conditions AS (SELECT*,(CASEWHEN CAST(state AS DOUBLE) = 1 THEN 'resolved'WHEN CAST(state AS DOUBLE) = 2 THEN 'cancelled'END) AS statusFROMazuro_polygon.PrematchCore_evt_ConditionResolved),PendingSingleBetsOnPlygonUsdtOfRidotto AS (SELECTusdtbetsfbs.bettor,cast(usdtbetsfbs.amount as double) / 1e6 as amount,usdtbetsfbs.evt_block_time as bet_timeFROMusdtbetsfbsLEFT JOIN conditions ON usdtbetsfbs.conditionId = conditions.conditionIdWHEREusdtbetsfbs.affiliate = 0x1D4bcFfcEDE6004241a8827D5C2457c01d5c9112AND conditions.state IS NULL),CombinedBets AS (SELECTbettor,DATE(bet_time) AS bet_dateFROMquery_2832316 -- all resolved betsWHEREaffiliate = 0x1D4bcFfcEDE6004241a8827D5C2457c01d5c9112UNION ALLSELECTbettor,DATE(bet_time) AS bet_dateFROMquery_3286939 -- all active combos betsWHEREaffiliate = 0x1D4bcFfcEDE6004241a8827D5C2457c01d5c9112