Votes distribution of regular users who have cast votes

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

DECLARE @Interval int = 100
DECLARE @IsRemoveLeast bit = 'false'

SELECT
  VotesFloor,
  COUNT(*) AS UserCount
FROM
  (SELECT
     FLOOR((UpVotes + DownVotes) / @Interval) * @Interval AS VotesFloor
   FROM
     Users
   WHERE
     UpVotes + DownVotes > 0 AND ID > 0
  ) AS Hist
WHERE
  @IsRemoveLeast != 1 OR (VotesFloor != 0)
GROUP BY
  VotesFloor
ORDER BY
  VotesFloor DESC

Enter Parameters

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