Generated controversity by month

1

Please login or register to vote for this query.

(click on this box to dismiss)

Esperanto Language

Q&A for teachers and students of the Esperanto language

WITH Raw AS (
  SELECT
    DATEFROMPARTS(
      DATEPART(yyyy, CreationDate),
      DATEPART(mm, CreationDate),
      1) AS Month,
    PostId,
    COUNT(CASE WHEN VoteTypeId = 2 THEN 1 END) AS Ups,
    COUNT(CASE WHEN VoteTypeId = 3 THEN 1 END) AS Downs
  FROM Votes
  WHERE VoteTypeId BETWEEN 2 AND 3
  GROUP BY PostId, DATEFROMPARTS(
    DATEPART(yyyy, CreationDate),
    DATEPART(mm, CreationDate),
    1)
)
SELECT
  Month,
  SUM(CASE WHEN Ups > Downs THEN Downs ELSE Ups END) AS Controversity
FROM Raw
GROUP BY Month
ORDER BY Month

Enter Parameters

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