select top 100 v.postid as [Post Link] , sum(case when v....

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

select top 100 v.postid as [Post Link]
     , sum(case when v.votetypeid = 2 then 1 else 0 end) up
     , sum(case when v.votetypeid = 3 then 1 else 0 end) down
     , sum(case when v.votetypeid = 8 then 1 else 0 end) bounties
from votes  v
where v.votetypeid in (2 ,3 , 8) --up/down/ bounty
group by v.postid
having sum(case when v.votetypeid = 8 then 1 else 0 end) > 0
order by 
   -- down votes
   sum(case when v.votetypeid = 3 then 1 else 0 end)  desc 
 , sum(case when v.votetypeid = 2 then 1 else 0 end) asc -- upvotes

Enter Parameters

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