Query editor
WITH latest_growth AS (SELECT MAX(run_id) AS rid FROM dune.w3io.dealsync_growth),latest_network AS (SELECT MAX(run_id) AS rid FROM dune.w3io.dealsync_network),growth AS (SELECTdate,SUM(new_users) OVER (ORDER BY date) AS cumulative_users,SUM(new_deals) OVER (ORDER BY date) AS cumulative_deals,new_users,new_dealsFROM dune.w3io.dealsync_growth tJOIN latest_growth l ON t.run_id = l.rid),network AS (SELECTdate,MAX(new_brands) OVER (ORDER BY date) AS cumulative_brandsFROM dune.w3io.dealsync_network tJOIN latest_network l ON t.run_id = l.rid),daily AS (SELECTg.date,g.cumulative_users,g.cumulative_deals,COALESCE(n.cumulative_brands, 0) AS cumulative_brands,g.new_users,g.new_dealsFROM growth gLEFT JOIN network n ON g.date = n.date)SELECTDATE_TRUNC('month', CAST(date AS TIMESTAMP)) AS month,MAX(cumulative_users) AS total_users,MAX(cumulative_deals) AS total_deals,MAX(cumulative_brands) AS total_brands,SUM(new_users) AS new_users,SUM(new_deals) AS new_dealsFROM dailyGROUP BY 1ORDER BY 1