Cross-Tag Tag Usage Breakdown

0

Please login or register to vote for this query.

(click on this box to dismiss)

A breakdown and sum of each and every tag utilized alongside a given tag on posts tagged with the given tag (Honestly can't figure out how to phrase this better).

Philosophy Meta

Q&A about the site for those interested in the study of the fundamental nature of knowledge, reality, and existence

DECLARE @TagId int = (
SELECT
  t.Id
FROM Tags t
WHERE t.TagName = ##TagName:string##
)

SELECT
  COUNT(otherTags.TagId) AS [Usage Count],
  t.TagName
FROM PostTags ptg
JOIN PostTags otherTags ON otherTags.PostId = ptg.PostId
JOIN Tags t ON t.Id = otherTags.TagId
WHERE ptg.TagId = @TagId AND otherTags.TagId <> @TagId
GROUP BY otherTags.TagId, t.TagName
UNION ALL
SELECT
  COUNT(TagId) AS [Usage Count],
  '(Total Questions)' AS [TagName]
FROM PostTags
WHERE TagId = @TagId
ORDER BY COUNT(otherTags.TagId) DESC

-- TagName: Exact Name of Tag:

Enter Parameters

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