Reasons for downvotes

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 cr.Name, COUNT(DISTINCT p.Id) AS CountTotal,
  COUNT(DISTINCT CASE WHEN p.ClosedDate IS NULL THEN p.Id ELSE NULL END) AS CountClosed
FROM Posts AS p
LEFT OUTER JOIN PendingFlags AS pf ON p.Id = pf.PostId
LEFT OUTER JOIN CloseReasonTypes AS cr ON pf.CloseReasonTypeId = cr.Id
WHERE p.CreationDate BETWEEN '2017-01-01' AND '2017-11-30'
AND p.PostTypeId = 1
GROUP BY cr.Name

Enter Parameters

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