SELECT CONVERT(DATETIME, CONCAT(YEAR(CreationDate), '-', ...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow em Português

Q&A for professional and enthusiast programmers

SELECT 
CONVERT(DATETIME, CONCAT(YEAR(CreationDate), '-', MONTH(CreationDate), '-01'), 20) AS Mes,
COUNT(*) AS 'Total no mês',
SUM (CASE WHEN VoteTypeId = 2 THEN 1 ELSE 0 END) AS 'Up', 
SUM (CASE WHEN VoteTypeId = 3 THEN 1 ELSE 0 END) AS 'Down'
FROM Votes 
WHERE VoteTypeId IN(2,3) -- Up, Down
GROUP BY YEAR(CreationDate), MONTH(CreationDate)
ORDER BY YEAR(CreationDate), MONTH(CreationDate)

Enter Parameters

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