distribution of up and down votes

0

Please login or register to vote for this query.

(click on this box to dismiss)

Christianity

Q&A for committed Christians, experts in Christianity and those interested in learning more

with p as (
   select id
   from PostsWithDeleted
   where PostTypeId = 2
)   ,a as (
select p.id,
       sum(case when v.votetypeid = 2 then 1 else 0 end) as upvotes, 
       sum(case when v.votetypeid = 3 then 1 else 0 end) as downvotes 
from p join votes v 
on p.id = v.PostId
group by p.id
)

select upvotes, downvotes, count(id) from a 
group by upvotes, downvotes
order by upvotes,downvotes

Enter Parameters

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