There's Just No Pleasing Some People

1

Please login or register to vote for this query.

(click on this box to dismiss)

Top 100 most highly upvoted posts that still earnt a downvote from a contrarian.

Engineering

Q&A for professionals and students of engineering

CREATE TABLE #PostVoteCounts 
  (Id int,
   UpVotes int,
   DownVotes int)
go

INSERT INTO #PostVoteCounts 
SELECT
  Votes.PostId,
  SUM(CASE WHEN Votes.VoteTypeId = 2 THEN 1 ELSE 0 END) as UpVotes, 
  SUM(CASE WHEN Votes.VoteTypeId = 3 THEN 1 ELSE 0 END) as DownVotes
FROM Votes
GROUP BY Votes.PostId
go

SELECT TOP 100 Id as [Post Link], Upvotes, DownVotes
FROM #PostVoteCounts 
WHERE DownVotes >= 1
ORDER BY UpVotes/DownVotes desc

Enter Parameters

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