questions per tag (count, answered, unanswered, accepted)

0

Please login or register to vote for this query.

(click on this box to dismiss)

this excludes deleted posts

Biology

Q&A for biology researchers, academics, and students

select tagname
     , count(*) [tot Q.]
     , sum(case when p.answercount > 0 then 1 else 0 end) [q answered . ]
     , sum(case when p.answercount = 0 then 1 else 0 end) [q not answered . ]
     , sum(case when p.acceptedanswerid is not null then 1 else 0 end) [q has accepted A]
from tags t
inner join posttags pt on pt.tagid = t.id
inner join posts p on p.id = pt.postid
group by tagname
order by count(*) desc;


/* experiment to find all posttags */
/*
select pwd.id [postid]
     , t.id [tagid]
into #posttagsdeleted
from postswithdeleted pwd
cross apply string_split(tags,'<') tagnames
inner join tags t on t.tagname = replace(tagnames.value,'>', '')
go
select *
from #posttagsdeleted

select *
from postswithdeleted
where deletiondate is not null
*/

Enter Parameters

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