Query editor
WITH l_ AS (SELECT l.* FROM dune.kxnshwdwn.result_showdown_ledger l LEFT JOIN dune.kxnshwdwn.dataset_showdown_games g ON g.id = l.platform_id WHERE '{{game}}' = 'All' OR ('{{game}}' = 'CS2' AND g.game = 'CS2') OR ('{{game}}' = 'Chess' AND g.game = 'LICHESS'))SELECT date_trunc('month', block_date) AS month,round(sum(CASE WHEN product = 'duel' AND flow = 'stake_deposit' THEN coalesce(amount_usd, amount) ELSE 0 END), 2) AS duel_stakes_usd,round(sum(CASE WHEN product = 'tournament' AND flow = 'stake_deposit' THEN coalesce(amount_usd, amount) ELSE 0 END), 2) AS tournament_stakes_usd,round(sum(CASE WHEN flow = 'sponsor_deposit' THEN coalesce(amount_usd, amount) ELSE 0 END), 2) AS sponsor_pools_usdFROM l_WHERE flow IN ('stake_deposit','sponsor_deposit')GROUP BY 1 ORDER BY 1