Top downvoters

0

Please login or register to vote for this query.

(click on this box to dismiss)

Craft CMS Meta

Q&A about the site for administrators, end users, developers and designers for Craft CMS

-- 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.

select
    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

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results