Shows all tags with at least 3000 questions, their total questions and of those, how many are unanswered.
Q&A for professional and enthusiast programmers
-- Unanswered Questions by Tag -- Shows all tags with at least 3000 questions, their total questions and -- of those, how many are unanswered. DECLARE @minQuestionCount int = 3000 SELECT * FROM ( -- All unanswered questions grouped by tag SELECT t.TagName AS TagName, COUNT(1) AS UnansweredCount, t.Count AS QuestionCount FROM Posts q INNER JOIN PostTags pt ON q.Id = pt.PostId INNER JOIN Tags t ON pt.TagId = t.Id WHERE (q.PostTypeId = 1) AND (q.ClosedDate IS NULL) AND NOT EXISTS ( SELECT * FROM Posts a WHERE (a.ParentId = q.Id) AND ((a.Score > 0) OR (a.Id = q.AcceptedAnswerId)) ) GROUP BY TagName, t.Count ) a WHERE a.QuestionCount > @minQuestionCount ORDER BY TagName