Q&A for professional and enthusiast programmers
SELECT FORMAT(CreationDate, 'yyyy-MM') as Month, COUNT(CASE WHEN PostTypeId = 1 THEN 1 END) as QuestionsPosted, COUNT(CASE WHEN PostTypeId = 2 THEN 1 END) as AnswersPosted FROM Posts WHERE PostTypeId IN (1, 2) AND CreationDate >= DATEADD(month, -24, GETDATE()) GROUP BY FORMAT(CreationDate, 'yyyy-MM') ORDER BY Month;