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 Meta en español

Preguntas y respuestas sobre el sitio 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 Isnull(parentid, 0)
             WHEN 0 THEN 1
             ELSE 0
           END)                                  AS "#Questions",
       Sum(CASE Isnull(parentid, 0)
             WHEN 0 THEN 0
             ELSE 1
           END)                                  AS "#Answers"
FROM   posts
WHERE  LEFT(CONVERT(CHAR, creationdate, 111), 7) BETWEEN ##start## AND ##end##
GROUP  BY LEFT(CONVERT(CHAR, creationdate, 111), 7)
ORDER  BY 1 ASC

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results