Percent of posts tagged with only [tag] with no answers and low [views]

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

declare @views int = ##viewed:int?1000##
declare @comments int = ##comments:int?-1##
declare @tagToSearch nvarchar(35) = ##tag:string?all##

select
  TagName,
  count(Posts.Id) as [No Answers],
  count(Posts.Id) * 100 / ( 
    select count(Id) from Posts where Posts.Tags = '<' + TagName + '>' 
  ) as Percentage
from
  Tags
  left join Posts on Posts.Tags = '<' + TagName + '>'
where
  Tags.Count > 0 
  and Posts.AnswerCount = 0 
  and Posts.Score >= 0 
  and Posts.ViewCount <= @views
  and TagName like ('%' + iif(@tagToSearch != 'all',@tagToSearch,'') + '%')
  and Posts.CommentCount <= iif(@comments < 0,Posts.CommentCount,@comments)
group by
  TagName
order by
  Percentage
desc

Enter Parameters

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