Q&A for developers building blockchains with the Substrate SDK
WITH PostTagCounts AS ( SELECT P.Id AS PostId, P.OwnerUserId AS UserId, P.Body AS PostBody, COUNT(PT.TagId) AS NumberOfTags FROM Posts P JOIN PostTags PT ON P.Id = PT.PostId GROUP BY P.Id, P.OwnerUserId, P.Body HAVING COUNT(PT.TagId) >= 5 ) SELECT STRING_AGG(T.TagName, ',') AS Tags, PTC.NumberOfTags, PTC.PostId, PTC.UserId, PTC.PostBody FROM PostTagCounts PTC JOIN PostTags PT ON PTC.PostId = PT.PostId JOIN Tags T ON PT.TagId = T.Id GROUP BY PTC.PostId, PTC.UserId, PTC.PostBody, PTC.NumberOfTags;