Controversial posts

0

Please login or register to vote for this query.

(click on this box to dismiss)

Posts that have at least five upvotes _and_ at least five downvotes, for the Controversial badge request Contributed by Andriy M - see SO question 6986461

Stack Overflow

Q&A for professional and enthusiast programmers

-- Controversial posts
-- Posts that have at least five upvotes _and_ at least five downvotes
-- For Controversial badge request
-- Contributed by Andriy M - see SO question 6986461

SELECT
  PostId as [Post Link],
  COUNT(CASE VoteTypeId WHEN 2 THEN 1 END) AS 'Upvote count',
  COUNT(CASE VoteTypeId WHEN 3 THEN 1 END) AS 'Downvote count'
FROM Votes v
INNER JOIN Posts p
ON p.Id=v.PostId
WHERE PostTypeId = 1
  AND VoteTypeId IN (2, 3)
GROUP BY v.PostId
HAVING COUNT(CASE VoteTypeId WHEN 2 THEN v.PostId END) > 5
   AND COUNT(CASE VoteTypeId WHEN 3 THEN v.PostId END) > 5

Enter Parameters

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