Suggested Edit Approval Rate, removing outliers

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

with user_votes as (
select userid
     , cast(sum(case when votetypeid = 2 then 1 
                     else 0 
                end) as float) as approved
     , cast(sum(case when votetypeid = 3 then 1 
                     else 0 
                end) as float) as rejected
     , count(*) as total
  from suggestededitvotes
 group by userid
having count(*) <> sum(case when votetypeid = 2 then 1 else 0 end)
   and count(*) > 10
       )
select cast(avg(approved * 100 / total) as numeric(5,2)) as [Approval Rate]
     , cast(avg(rejected * 100 / total) as numeric(5,2))as [Rejection Rate]
     , cast(avg(approved) as numeric(5,2)) as [Average Approved]
     , cast(avg(rejected) as numeric(5,2)) as [Average Rejected]
     , cast(avg(total) as numeric(5,2)) as [Average Votes]
  from user_votes

Enter Parameters

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