Q&A about the site for serious players and enthusiasts of chess
WITH DIS_VOTES AS ( SELECT DISTINCT V.PostID, V.VoteTypeId, Count(*) AS 'SUM' FROM Votes V GROUP BY V.PostID, V.VoteTypeId ) SELECT SUB.* FROM (SELECT DV.PostID ,VT.Name ,DV.SUM ,RANK() OVER(PARTITION BY VoteTypeId ORDER BY DV.SUM DESC) AS VOTE_RANK FROM DIS_VOTES DV INNER JOIN VoteTypes VT ON VT.Id = DV.VoteTypeId WHERE VT.Name IN ('UpMod','DownMod')) SUB WHERE SUB.VOTE_RANK <= 10