Q&A for professional and enthusiast programmers
SELECT Tags.TagName AS [Tag Name], COUNT(*) AS [Number of associated posts] FROM PostTags INNER JOIN Tags ON Tags.Id = PostTags.TagId WHERE PostTags.PostId IN ( --Gets all the PostIds that have this tag SELECT DISTINCT PostId FROM PostTags INNER JOIN Tags ON Tags.Id = PostTags.TagId WHERE Tags.TagName = ##TagName:string## ) AND Tags.TagName <> ##TagName:string## GROUP BY Tags.TagName ORDER BY COUNT(*) DESC