select t.tagname , sum(case when rt.reviewtaskstateid = 3...

1

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 t.tagname
, sum(case when rt.reviewtaskstateid = 3 then 1 else 0 end) as [invalidated]
, sum(case when rt.reviewtaskstateid <> 3 then 1 else 0 end) as [validated]
, count(*) as cnt
from reviewtasks rt
inner join posts p on p.id = rt.postid
inner join posttags pt on pt.postid = p.id
inner join tags t on t.id = pt.tagid
where rt.reviewtasktypeid =2 -- close
group by t.tagname
order by 
sum(case when rt.reviewtaskstateid = 3 then 1 else 0 end) / 
(sum(case when rt.reviewtaskstateid <> 3 then 1 else 0 end)+1)

Enter Parameters

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