Vote repartition by month

0

Please login or register to vote for this query.

(click on this box to dismiss)

Software Engineering

Q&A for expert programmers interested in professional discussions on software development

SELECT
  DateAdd(Month, DateDiff(Month, 0, CreationDate), 0) AS [Month],
  Count(*) AS [Total],
  Count(CASE VoteTypeID WHEN 2 THEN 1 END) AS [Up],
  Count(CASE VoteTypeID WHEN 3 THEN 1 END) AS [Down],
  100.0 * Count(CASE VoteTypeID WHEN 3 THEN 1 END) / Count(*) AS [Down%]
FROM Votes
WHERE (VoteTypeId = 2 OR VoteTypeId = 3)
GROUP BY DateDiff(Month, 0, CreationDate)
ORDER BY [Month]

Enter Parameters

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