Q&A about the site for SharePoint enthusiasts
WITH PostWithTagCounts AS ( SELECT Top 10 Posts.Id AS PostId, Posts.OwnerUserId AS UserId, Posts.Body AS PostBody, COUNT(PostTags.TagId) AS NumberOfTags, STRING_AGG(Tags.TagName, ', ') AS Tags FROM Posts JOIN PostTags ON Posts.Id = PostTags.PostId JOIN Tags ON PostTags.TagId = Tags.Id WHERE Posts.Tags IS NOT NULL GROUP BY Posts.Id, Posts.OwnerUserId, Posts.Body ) SELECT * FROM PostWithTagCounts WHERE NumberOfTags >= 5 ORDER BY NumberOfTags DESC;