SELECT STRING_AGG(t.TagName, ', ') AS Tags, -- ...

0

Please login or register to vote for this query.

(click on this box to dismiss)

GenAI Meta

Q&A for GenAI enthusiasts and practitioners and those interested in learning more about using GenAI tools

SELECT 
    STRING_AGG(t.TagName, ', ') AS Tags,           -- Comma-separated list of tags
    COUNT(t.TagName) AS NumberOfTags,              -- Number of tags
    p.Id AS PostId,                                -- Post ID
    p.OwnerUserId AS UserId,                       -- User ID of the post owner
    p.Body AS PostBody                             -- The body of the post
FROM Posts p
JOIN PostTags pt ON p.Id = pt.PostId               -- Join between Posts and PostTags to get tags
JOIN Tags t ON pt.TagId = t.Id                     -- Join between PostTags and Tags to get tag names
GROUP BY p.Id, p.OwnerUserId, p.Body               -- Group by PostId, UserId, and PostBody
HAVING COUNT(t.TagName) >= 5;

Enter Parameters

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