Query editor
WITHgnosis_token_labels AS (SELECT * FROM query_4302711),trades AS (SELECTblock_date,sector,amount_usd,amount_usd/(SUM(amount_usd) OVER(PARTITION BY block_date)) AS fracFROM (SELECTCONCAT(CAST(YEAR(t1.block_date) AS VARCHAR),' - Q', CAST(QUARTER(t1.block_date) AS VARCHAR)) AS block_date,CASEWHEN t2.sector = 'Stable' AND t3.sector = 'Stable'THEN IF(t2.currency=t3.currency, 'Stable Conversion', 'Forex')WHEN (t2.sector = 'Stable' AND t3.sector = 'Crypto')OR(t3.sector = 'Stable' AND t2.sector = 'Crypto')THEN 'Stable <-> Crypto'ELSE 'Crypto <-> Crypto'END AS sector,SUM(amount_usd) AS amount_usdFROM dex.trades t1INNER JOINgnosis_token_labels t2ON t2.token_address = t1.token_bought_addressINNER JOINgnosis_token_labels t3ON t3.token_address = t1.token_sold_addressWHEREt1.block_date >= CURRENT_DATE - INTERVAL '1' YEARANDt1.blockchain = 'gnosis'GROUP BY 1, 2))SELECT*FROMtradesORDER BYsector ASC