Q&A about the site for Muslims, experts in Islam, and those interested in learning more about Islam
declare @n int = ##n##; with RankTag as ( select top (@n) pt.TagId , count(1) tagPostCount , row_number() over (order by count(1) desc) tagRank from PostTags pt group by tagid order by count(1) desc ) select Tags.TagName, RankTag.tagRank, RankTag.tagPostCount from RankTag inner join Tags on Tags.id = RankTag.TagId order by RankTag.tagRank;