SELECT DATEADD(MONTH, DATEPART(MONTH, p.CreationDate), CO...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Meta Stack Exchange

Q&A for meta-discussion of the Stack Exchange family of Q&A websites

SELECT
  DATEADD(MONTH, DATEPART(MONTH, p.CreationDate),
          CONCAT(DATEPART(YEAR, p.CreationDate), '-01-01')) AS [Created],
  COUNT(IIF(p.ClosedDate IS NULL, p.Id, NULL)) AS [OpenCount],
  COUNT(IIF(p.ClosedDate IS NOT NULL, p.Id, NULL)) AS [ClosedCount]
FROM PostsWithDeleted p
INNER JOIN Users u ON p.OwnerUserId = u.Id
WHERE
  p.PostTypeId = 1 AND
  p.CreationDate >= DATEADD(YEAR, -1, GETDATE()) AND
  u.Reputation <= 5
GROUP BY DATEADD(MONTH, DATEPART(MONTH, p.CreationDate),
                 CONCAT(DATEPART(YEAR, p.CreationDate), '-01-01'))
ORDER BY DATEADD(MONTH, DATEPART(MONTH, p.CreationDate),
                 CONCAT(DATEPART(YEAR, p.CreationDate), '-01-01')) ASC;

Enter Parameters

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