Negatively scored answers on Stack Overflow - upvote, downvote, and acceptance breakouts

1

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
  p.Score,
  count(*) as total_votes,
  SUM(CASE WHEN v.VoteTypeId = 2 THEN 1 ELSE 0 END) AS total_upvote_count,
  SUM(CASE WHEN v.VoteTypeId = 3 THEN 1 ELSE 0 END) AS total_downvote_count,
  SUM(CASE WHEN v.VoteTypeId = 1 THEN 1 ELSE 0 END) AS total_accepted_answer_count,
  CAST(SUM(CASE WHEN v.VoteTypeId = 2 THEN 1 ELSE 0 END) AS DECIMAL)/count(*) * 100 AS average_pct_upvote,
  CAST(SUM(CASE WHEN v.VoteTypeId = 1 THEN 1 ELSE 0 END) AS DECIMAL)/count(*) * 100 AS average_pct_accepted
FROM Posts p
  LEFT JOIN Votes v ON p.Id = v.PostId
WHERE p.PostTypeId = 2
GROUP BY p.Score
HAVING p.Score <= -1 AND p.Score >= -100
ORDER BY p.Score DESC

Enter Parameters

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