Most controversial posts on the site

1

Please login or register to vote for this query.

(click on this box to dismiss)

This query shows those posts where the down-votes are more than half of the up-votes. It doesn't include posts where both the up-votes, and the down-votes are 1.

Engineering

Q&A for professionals and students of engineering

SET NOCOUNT ON

DECLARE @VoteStats TABLE (PostId int, up int, down int) 

INSERT @VoteStats
SELECT
    PostId, 
    up = SUM(CASE WHEN VoteTypeId = 2 THEN 1 ELSE 0 END), 
    down = SUM(CASE WHEN VoteTypeId = 3 THEN 1 ELSE 0 END)
FROM Votes
WHERE VoteTypeId in (2,3)
GROUP BY PostId

SET NOCOUNT OFF

SELECT TOP 100 p.id AS [Post Link], up AS [Up-votes], down AS [Down-votes] FROM @VoteStats 
join Posts p ON PostId = p.Id
WHERE
  down <> up
    AND down > (up * 0.5)
    AND p.CommunityOwnedDate IS NULL
    AND p.ClosedDate IS NULL
ORDER BY up DESC

Enter Parameters

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