SELECT FORMAT(CreationDate, 'yyyy-MM') as Month, COUNT(CA...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

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;

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results