Query editor
WITH monthly_volume AS (SELECTDATE_TRUNC('month', block_time) AS month,project,SUM(amount_usd) AS volumeFROM dex_solana.tradesGROUP BY 1,2),monthly_total AS (SELECTmonth,SUM(volume) AS total_volumeFROM monthly_volumeGROUP BY month),market_share AS (SELECTmv.month,mv.project,(mv.volume / mt.total_volume) * 100 AS shareFROM monthly_volume mvJOIN monthly_total mtON mv.month = mt.month)SELECTmonth,project,ROUND(share,2) AS market_share,ROUND(share - LAG(share) OVER (PARTITION BY projectORDER BY month),2) AS change_from_last_monthFROM market_shareORDER BY month DESC, change_from_last_month DESC;