Upvoted questions where all answers are downvoted

2

Please login or register to vote for this query.

(click on this box to dismiss)

Code Review

Q&A for peer programmer code reviews

SELECT
  q.Id AS [Post Link],
  MAX(q.Score) AS [Score],
  COUNT(a.Id) AS [AnswerCount],
  AVG(CAST(a.Score AS float)) AS [AvgAnswerScore]
FROM
  Posts AS q
  -- INNER JOIN => At least one answer
  INNER JOIN Posts AS a
    ON q.Id = a.ParentId
WHERE
  -- Question is upvoted
  q.Score >= 1
GROUP BY
  q.Id
HAVING
  -- Zero upvoted answers
  SUM((CASE WHEN a.Score >= 0 THEN 1 ELSE 0 END)) = 0
ORDER BY
  [Score] DESC,
  [AnswerCount] DESC

Enter Parameters

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