Q&A about the site for members of the workforce navigating the professional setting
WITH PostsWithTags AS ( SELECT PostTags.PostId, COUNT(PostTags.TagId) AS TagCount FROM PostTags GROUP BY PostTags.PostId HAVING COUNT(PostTags.TagId) >= 5 ) SELECT STRING_AGG(Tags.TagName, ', ') AS Tags, COUNT(Tags.TagName) AS NumberOfTags, Posts.Id AS PostId, Posts.OwnerUserId AS UserId, Posts.Body AS PostBody FROM Posts JOIN PostsWithTags ON Posts.Id = PostsWithTags.PostId JOIN PostTags ON Posts.Id = PostTags.PostId JOIN Tags ON PostTags.TagId = Tags.Id GROUP BY Posts.Id, Posts.OwnerUserId, Posts.Body ORDER BY Posts.Id;