Q&A about the site for professors, theologians, and those interested in exegetical analysis of biblical texts
;with counts_cte AS (SELECT PostId AS id, COUNT(RelatedPostId) AS count FROM PostLinks WHERE (LinkTypeId IN (##linktypes?1,3##)) GROUP BY PostId ---LinkTypeId type of link ---1 = Linked (PostId contains a link to RelatedPostId) ---3 = Duplicate (PostId is a duplicate of RelatedPostId) ) SELECT TOP(##num?500##) p.Id AS [Post Link], c.count, linked = 'site://questions/linked/' + CAST(p.Id AS varchar), p.Title, p.Score, p.ViewCount, p.AnswerCount, p.Tags FROM counts_cte c INNER JOIN Posts p ON p.id=c.id INNER JOIN PostTags pt ON p.Id=pt.PostId INNER JOIN Tags t ON t.id = pt.TagId WHERE t.TagName=##tagName:string?geometry## ORDER BY c.count DESC