Question 1

0

Please login or register to vote for this query.

(click on this box to dismiss)

The Workplace Meta

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;

Enter Parameters

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