Q&A for those using, extending or developing Emacs
-- Compared the original, this doesn't fail if the number -- of upvotes is zero (e.g., seen when running it on -- Stack Overflow): -- -- "Line 1: Divide by zero error encountered. The statement -- has been terminated." -- -- Though the ratio is no longer strictly correct in the -- absolute sense. But the sorting is not affected. That -- would probably be trivial to fix, e.g. by excluding -- users with zero upvotes. SELECT TOP 150 row_number() over (ORDER BY Downvotes DESC, Upvotes ASC, DisplayName, Id) as Rank, Id as [User Link], Downvotes, Upvotes, ((Cast(Downvotes as float)/(Upvotes+1))) as Ratio, LastAccessDate, CONVERT(varchar(10), CreationDate, 103) as "Desde" INTO #Downvoters FROM Users WHERE Id <> -1 and Downvotes >= 10 SELECT * FROM #Downvoters ORDER BY Rank SELECT Rank, Downvotes FROM #Downvoters ORDER BY Ratio DESC