Query editor
with tokentoquestion as (SELECT token0 as token, b.conditionid, a.questionId FROM predict_bnb.umacompatiblectfadapter_evt_questioninitialized aINNER JOIN predict_bnb.conditionaltokens_evt_conditionpreparation b ON a.questionId = b.questionIdINNER JOIN predict_bnb.ctfexchange_evt_tokenregistered c ON b.conditionId = c.conditionIdUNION ALLSELECT token0 as token, b.conditionid, a.questionId FROM predict_bnb.umacompatiblectfadapter_evt_questioninitialized aINNER JOIN predict_bnb.yieldbearingconditionaltokens_evt_conditionpreparation b ON a.questionId = b.questionIdINNER JOIN predict_bnb.ctfexchange_evt_tokenregistered c ON b.conditionId = c.conditionIdUNION ALLSELECT token0 as token, b.conditionid, a.questionId FROM predict_bnb.negriskadapter_evt_questionprepared aINNER JOIN predict_bnb.conditionaltokens_evt_conditionpreparation b ON a.questionId = b.questionIdINNER JOIN predict_bnb.negriskctfexchange_evt_tokenregistered c ON b.conditionId = c.conditionIdUNION ALLSELECT token0 as token, b.conditionid, a.questionId FROM predict_bnb.negriskadapter_evt_questionprepared aINNER JOIN predict_bnb.yieldbearingconditionaltokens_evt_conditionpreparation b ON a.questionId = b.questionIdINNER JOIN predict_bnb.negriskctfexchange_evt_tokenregistered c ON b.conditionId = c.conditionIdUNION ALLSELECT token0 as token, b.conditionid, a.questionId FROM predict_bnb.yieldbearingnegriskadapter_evt_questionprepared aINNER JOIN predict_bnb.conditionaltokens_evt_conditionpreparation b ON a.questionId = b.questionIdINNER JOIN predict_bnb.negriskctfexchange_evt_tokenregistered c ON b.conditionId = c.conditionIdUNION ALLSELECT token0 as token, b.conditionid, a.questionId FROM predict_bnb.yieldbearingnegriskadapter_evt_questionprepared aINNER JOIN predict_bnb.yieldbearingconditionaltokens_evt_conditionpreparation b ON a.questionId = b.questionIdINNER JOIN predict_bnb.negriskctfexchange_evt_tokenregistered c ON b.conditionId = c.conditionIdUNION ALLSELECT token0 as token, b.conditionid, a.questionId FROM predict_bnb.chainlinkupdownadapter_evt_chainlinkupdownadapter__roundcreated aINNER JOIN predict_bnb.conditionaltokens_evt_conditionpreparation b ON a.questionId = b.questionIdINNER JOIN predict_bnb.ctfexchange_evt_tokenregistered c ON b.conditionId = c.conditionId),vol as (SELECT DATE_TRUNC('month', evt_block_time) as "Month",CASEWHEN CAST(makerAssetId AS VARCHAR) = '0' THEN CAST(takerAmountFilled/2 AS DOUBLE) / 1e18WHEN CAST(takerAssetId AS VARCHAR) = '0' THEN CAST(makerAmountFilled/2 AS DOUBLE) / 1e18END AS "Notional Volume",CASEWHEN CAST(makerAssetId AS VARCHAR) = '0' THEN CAST(takerAssetId AS VARCHAR)WHEN CAST(takerAssetId AS VARCHAR) = '0' THEN CAST(makerAssetId AS VARCHAR)END AS "Token"FROM predict_bnb.ctfexchange_evt_orderfilledUNION ALLSELECT DATE_TRUNC('month', evt_block_time) as "Month",CASEWHEN CAST(makerAssetId AS VARCHAR) = '0' THEN CAST(takerAmountFilled/2 AS DOUBLE) / 1e18WHEN CAST(takerAssetId AS VARCHAR) = '0' THEN CAST(makerAmountFilled/2 AS DOUBLE) / 1e18END AS "Notional Volume",CASEWHEN CAST(makerAssetId AS VARCHAR) = '0' THEN CAST(takerAssetId AS VARCHAR)WHEN CAST(takerAssetId AS VARCHAR) = '0' THEN CAST(makerAssetId AS VARCHAR)END AS "Token"FROM predict_bnb.negriskctfexchange_evt_orderfilled),token_categories AS (SELECTtoken_id,CASEWHEN tag IN ('Esports', 'LoL', 'Dota 2', 'CSGO', 'CS2', 'Valorant') THEN 'Esports'WHEN tag IN ('Crypto', 'ETH', 'BTC') THEN 'Crypto'