select t.tagname , min(t.count) as tc , sum(case when rt....

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
, min(t.count) as tc
, 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
-- inner join posts exc on exc.id = t.excerptPostid
where rt.reviewtasktypeid =2 -- close
-- and exc.body like '%do not use%'
group by t.tagname
order by 
(sum(case when rt.reviewtaskstateid = 3 then 1 else 0 end) *100) / 
(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