WITH PostTagCombinations AS ( SELECT pt.PostId, STRING_AG...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Amateur Radio

Q&A for amateur radio enthusiasts

WITH PostTagCombinations AS (
    SELECT 
        pt.PostId,
        STRING_AGG(t.TagName, ',') WITHIN GROUP (ORDER BY t.TagName) AS TagCombination
    FROM PostTags pt,
         Tags t
    WHERE pt.TagId = t.Id
    GROUP BY pt.PostId
),
CombinationCounts AS (
    SELECT 
        TagCombination,
        COUNT(*) AS CombinationCount
    FROM PostTagCombinations
    GROUP BY TagCombination
)
SELECT TOP 5
    TagCombination, CombinationCount
FROM CombinationCounts
ORDER BY CombinationCount DESC;

Enter Parameters

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