Ratio of #votes per a user

0

Please login or register to vote for this query.

(click on this box to dismiss)

スタック・オーバーフロー

プログラマーとプログラミングに熱心な人々のための質問と回答

DECLARE @AllVotes float
SET @AllVotes = (SELECT SUM(UpVotes) + SUM(DownVotes) FROM Users WHERE Id > 0)
SELECT
  Id,
  CAST((UpVotes + DownVotes) AS float) / @AllVotes AS VoteRatio
FROM
  Users
WHERE
  Id > 0
GROUP BY
  Id, UpVotes, DownVotes
ORDER BY
  (UpVotes + DownVotes) DESC
OFFSET 0 ROWS
FETCH NEXT 100 ROWS ONLY

Enter Parameters

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