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 professional and enthusiast 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 #TotalVotes
set Upvotes = (
  select count(*) from Votes v 
  join Posts p on v.PostId = p.Id  
  where UserId = OwnerUserId 
    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 UserId = OwnerUserId 
    and ClosedDate is null 
    and CommunityOwnedDate is null
    and VoteTypeId = 3
) 

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

Enter Parameters

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