Meta posts with more than one required tag

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 @RelevantTags TABLE (Id Int);
INSERT INTO @RelevantTags(Id)
SELECT Id FROM Tags
WHERE TagName = 'discussion' OR TagName = 'support' OR TagName = 'bug' OR TagName = 'feature-request';

SELECT
  c.PostId AS [Post Link],
  c.Count,
  Replace(Replace(Left(p.Tags, Len(p.Tags)-1), Left(p.Tags, 1), ''), Right(p.Tags, 1), ' ') AS [Tags]
FROM (
  SELECT pt.PostId, Count(*) AS [Count]
  FROM PostTags pt
  INNER JOIN @RelevantTags rt ON rt.Id = pt.TagId
  GROUP BY pt.PostId
) c
LEFT JOIN Posts p ON p.Id = c.PostId
WHERE c.Count >= 2
ORDER BY c.PostId ASC

Enter Parameters

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