Q&A for users and developers of the Cardano cryptocurrency ecosystem
WITH Combos AS( SELECT pt.PostId, STRING_AGG(t.TagName,',') WITHIN GROUP (ORDER BY TagName ASC) AS TagCombo FROM PostTags pt JOIN Tags t ON pt.TagId = t.Id GROUP BY pt.PostId ), ComboCounts AS ( SELECT TagCombo, COUNT(PostId) Cnt FROM Combos GROUP BY TagCombo ) SELECT TOP 5 TagCombo, Cnt FROM ComboCounts ORDER BY Cnt DESC