Finds posts that have a large amount of upvotes and downvotes.
Q&A about the site for music historians, critics, and fans
;with UpvotedPosts as ( select p.Id, count(P.Id) [UpvoteCount] from Posts p inner join Votes v on v.PostId = p.Id and v.VoteTypeId = 2 --UpMod group by p.Id having count(p.Id) >= ##minUpvoteCount:int## ), DownvotedPosts as ( select p.Id, count(P.Id) [DownvoteCount] from Posts p inner join Votes v on v.PostId = p.Id and v.VoteTypeId = 3 --DownMod group by p.Id having count(p.Id) >= ##minDownvoteCount:int## ) select p.Id [Post Link], up.UpvoteCount, dp.DownvoteCount, abs(up.UpvoteCount - dp.DownvoteCount) [delta], up.UpvoteCount + dp.DownvoteCount [sum] from Posts p inner join UpvotedPosts up on p.Id = up.Id inner join DownvotedPosts dp on p.Id = dp.Id order by delta asc, [sum] desc