Problem Users

0

Please login or register to vote for this query.

(click on this box to dismiss)

Ordered by total downvotes / (total upvotes + total downvotes)

Stack Overflow

Q&A for programmers

-- Problem Users
-- Ordered by total downvotes / (total upvotes + total downvotes)

create table #TotalVotes(UserId int, Upvotes int, Downvotes int, Reputation int)

insert into #TotalVotes (UserId, Reputation) 
select Id, Reputation from Users where Reputation > 1000

update t 
set Upvotes = (
  select count(*) from Votes v 
  join Posts p on v.PostId = p.Id  
  where p.OwnerUserId = t.UserId and ClosedDate is null 
    and CommunityOwnedDate is null
    and VoteTypeId = 2
) , 
Downvotes  = (
  select count(*) from Votes v 
  join Posts p on v.PostId = p.Id  
  where p.OwnerUserId = t.UserId and  ClosedDate is null 
    and CommunityOwnedDate is null
    and VoteTypeId = 3
) 
from #TotalVotes t




select UserId as [User Link], Upvotes, Downvotes, Reputation from #TotalVotes
order by (DownVotes / (Upvotes + Downvotes + 0.00001)) desc 

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results
:records returned in :time ms:cached