Q&A about the site for members of the workforce navigating the professional setting
WITH MonthlyCounts AS ( SELECT DATEFROMPARTS(YEAR(CreationDate), MONTH(CreationDate), 1) AS [Month], PostTypeId, COUNT(*) AS PostCount FROM Posts WHERE CreationDate >= '2019-01-01' AND PostTypeId IN (1, 2) GROUP BY DATEFROMPARTS(YEAR(CreationDate), MONTH(CreationDate), 1), PostTypeId ) SELECT mc.[Month], SUM(CASE WHEN mc.PostTypeId = 1 THEN mc.PostCount ELSE 0 END) AS Questions, SUM(CASE WHEN mc.PostTypeId = 2 THEN mc.PostCount ELSE 0 END) AS Answers FROM MonthlyCounts mc GROUP BY mc.[Month] ORDER BY mc.[Month] DESC;