Number of Questions and Answers per Month in a given YYYY/MM range

1

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow en español

Preguntas y respuestas para programadores y profesionales de la informática

-- start and end need to be in this format
-- yyyy/mm examples:
-- '2015/10' 
-- '2016/01'
-- ALERT: those values require to use single quotes

SELECT LEFT(CONVERT(CHAR, creationdate, 111), 7) AS CreatedOn,
       Sum(CASE PostTypeId
             WHEN 1 THEN 1
             ELSE 0
           END)                                  AS "#Questions",
       Sum(CASE PostTypeId
             WHEN 2 THEN 1
             ELSE 0
           END)                                  AS "#Answers"
FROM   posts
WHERE  LEFT(CONVERT(CHAR, creationdate, 111), 7) BETWEEN ##start## AND ##end##
       AND PostTypeId IN (1,2)
GROUP  BY LEFT(CONVERT(CHAR, creationdate, 111), 7)
ORDER  BY 1 ASC

Enter Parameters

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