Most controversial users

1

Please login or register to vote for this query.

(click on this box to dismiss)

Raspberry Pi

Q&A for users and developers of hardware and software for Raspberry Pi

WITH Raw AS (
  SELECT
    MIN(Posts.OwnerUserId) AS UserId,
    COUNT(CASE WHEN Votes.VoteTypeId = 2 THEN 1 END) AS Ups,
    COUNT(CASE WHEN Votes.VoteTypeId = 3 THEN 1 END) AS Downs
  FROM Posts, Votes
  WHERE
    Votes.PostId = Posts.Id
    AND
    Votes.VoteTypeId BETWEEN 2 AND 3
    AND
    Posts.OwnerUserId > 0
  GROUP BY Posts.Id
)
SELECT TOP 1000
  UserId AS [User Link],
  SUM(Ups) AS TotalUps,
  SUM(Downs) AS TotalDowns,
  100.0 * SUM(Ups) / (SUM(Ups) + SUM(Downs)) AS UpPercent,
  SUM(CASE WHEN Ups > Downs THEN Downs ELSE Ups END) AS Controversity
FROM Raw
GROUP BY UserId
ORDER BY Controversity DESC, UserId

Enter Parameters

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