Total rep gained on the site for posts not older than 30 days, by month

1

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow на русском Meta

Вопросы и ответы о сайте для программистов

SELECT
  DATEFROMPARTS(YEAR(Votes.CreationDate), MONTH(Votes.CreationDate), 1)
    AS Month,
  SUM(
    CASE
      WHEN Votes.VoteTypeId = 1 THEN 15
      WHEN Votes.VoteTypeId = 2 THEN 10
      ELSE -2
    END) AS Rep
FROM Posts, Votes
WHERE
  Votes.PostId = Posts.Id
  AND
  DATEDIFF(day, Posts.CreationDate, Votes.CreationDate) BETWEEN 0 AND 30
  AND
  Votes.VoteTypeId <= 3
GROUP BY
  DATEFROMPARTS(YEAR(Votes.CreationDate), MONTH(Votes.CreationDate), 1)
ORDER BY Month DESC;

Enter Parameters

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