Query editor
WITH ranked AS (SELECT *,ROW_NUMBER() OVER (PARTITION BY token_idORDER BY last_uploaded_at DESC) AS rnFROM polymarket_polygon.market_detailsWHERE question LIKE '%Mexico%'AND question LIKE '%South Africa%'),classified AS (SELECTtoken_id,question,event_market_name,CASEWHEN lower(question) LIKE '%exact score%' THEN 'Exact Score'WHEN lower(question) LIKE '%corner%' THEN 'Corners'WHEN lower(question) LIKE '%both teams to score%' THEN 'Both Teams To Score'WHEN lower(question) LIKE '%1st half%' THEN 'Halftime'WHEN lower(question) LIKE '%o/u%' AND lower(question) NOT LIKE '%corner%' THEN 'Totals'WHEN lower(question) LIKE '%draw%' THEN 'Match Result'WHEN lower(question) LIKE '%score first%' THEN 'First Event'ELSE 'Other'END AS market_typeFROM rankedWHERE rn = 1),trades AS (SELECTasset_id,block_time,shares * price AS usd_volumeFROM polymarket_polygon.market_trades),joined AS (SELECTc.market_type,t.block_time,t.usd_volumeFROM trades tINNER JOIN classified cON t.asset_id = c.token_id),normalized AS (SELECTmarket_type,block_time,usd_volume,-- normalize time per category using to_unixtime instead of EXTRACT(EPOCH FROM ...)(to_unixtime(block_time)- MIN(to_unixtime(block_time)) OVER (PARTITION BY market_type))/