distribution of up and down votes


Please login or register to vote for this query.

(click on this box to dismiss)

Android Enthusiasts Meta

Q&A about the site for enthusiasts and power users of the Android operating system

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
), m as (
    select upvotes, downvotes, count(id) as cnt from a 
    group by upvotes, downvotes
), sm as (
    select upvotes, sum(cnt) vsum
    from m
    group by upvotes

select m.downvotes,1.00*cnt/vsum
from m join sm on m.upvotes = sm.upvotes 
where m.upvotes = 0
order by m.downvotes

Enter Parameters

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