List of Tags of users questions and answers

0

Please login or register to vote for this query.

(click on this box to dismiss)

Musical Practice and Performance Meta

Q&A about the site for musicians, students, and enthusiasts

WITH CombinedTags AS (
    SELECT 
        Users.Id as UserId,
        Users.DisplayName, 
        Users.AboutMe,
        Users.Location,
        Tags.TagName
    FROM Comments
    INNER JOIN Posts ON Posts.Id = Comments.PostId
    INNER JOIN Posts AS PostsP ON PostsP.Id = Posts.ParentId
    INNER JOIN PostTags ON PostTags.PostId = PostsP.Id
    INNER JOIN Tags ON PostTags.TagId = Tags.Id
    INNER JOIN Users ON Users.Id = Comments.UserId
    WHERE Users.Location = 'Athens'

    UNION ALL

    SELECT 
        Users.Id as UserId,
        Users.DisplayName, 
        Users.AboutMe,
        Users.Location,
        Tags.TagName
    FROM Users
    INNER JOIN Posts ON Posts.OwnerUserId = Users.Id
    INNER JOIN PostTags ON PostTags.PostId = Posts.Id
    INNER JOIN Tags ON PostTags.TagId = Tags.Id
    WHERE Users.Location = 'Athens'
)

SELECT 
    UserId,

    STRING_AGG(CAST(TagName AS NVARCHAR(MAX)), ';') AS Tags
FROM CombinedTags
GROUP BY UserId
ORDER BY Tags ASC;

Enter Parameters

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