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 "#Posts", 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