SELECT FORMAT(Votes.CreationDate, 'yyyy-MM') AS [Month], ...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

SELECT
  FORMAT(Votes.CreationDate, 'yyyy-MM') AS [Month],
  SUM(CASE WHEN VoteTypeId = 2 THEN 1 ELSE 0 END) AS Upvotes,
  SUM(CASE WHEN VoteTypeId = 3 THEN 1 ELSE 0 END) AS Downvotes
FROM
  Votes
WHERE
  Votes.VoteTypeId IN (2, 3) -- 2 is UpMod (upvote), 3 is DownMod (downvote)
  AND Votes.CreationDate >= '2021-11-01'
  AND Votes.CreationDate < '2023-11-01'
GROUP BY
  FORMAT(Votes.CreationDate, 'yyyy-MM')
ORDER BY
  [Month] ASC;

Enter Parameters

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