Show some values often used for burninate-requests
Q&A for professional and enthusiast programmers
DECLARE @TagName nvarchar(25) = '##TagName##' SELECT --Question count COUNT(Posts.Id) as [Post Count], --Question count with tag in title SUM(CASE WHEN LOWER(Posts.Title) LIKE '%' + @TagName + '%' THEN 1 ELSE 0 END) AS [In Title], --Percentage count/count with tag in title (CAST(SUM(CASE WHEN LOWER(Posts.Title) LIKE '%' + @TagName + '%' THEN 1 ELSE 0 END) AS float) / COUNT(Posts.Id) * 100) AS [Percent], --count of tags alone (no other tags tagged in the question) SUM(CASE WHEN Posts.Tags LIKE '<' + @TagName + '>' THEN 1 ELSE 0 END) AS [Tags alone] FROM PostTags INNER JOIN Tags ON PostTags.TagId = Tags.Id INNER JOIN Posts ON PostTags.PostId = Posts.Id WHERE TagName = @TagName;