Breakdown of posts with 0 score

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

WITH VotesPerPost AS (SELECT p.Id, p.PostTypeId,
  COALESCE(COUNT(v.Id), 0) AS Votes
  FROM Posts AS p
  LEFT OUTER JOIN Votes AS v
    ON p.Id = v.PostId
   AND v.VoteTypeId = 2 -- upvotes
  WHERE Score = 0
    AND PostTypeId IN (1, 2) -- questions, answers
  GROUP BY p.Id, p.PostTypeId)
  
SELECT Votes, COUNT(*) AS 'All posts',
  SUM(CASE PostTypeId WHEN 1 THEN 1 ELSE 0 END) AS 'Questions',
  SUM(CASE PostTypeId WHEN 2 THEN 1 ELSE 0 END) AS 'Answers'
  FROM VotesPerPost  
  GROUP BY Votes
  ORDER BY Votes

Enter Parameters

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