I am working on stackoverflow sqlquery portal. I want to have top 1000 tags with maximum post count. and for each tag need id of 60 post which have that tag as their tag. so i need to loop across all 100 tags and and get top 60 postid linked with them. sombody help please.
her's my sql statement.
SELECT Top 60 PostId,ok.Id
FROM PostTags as test
INNER JOIN (SELECT TOP 50
Id,Count
FROM Tags
ORDER BY Tags.Count DESC) as ok
ON ok.Id = test.TagId
but it returns only 60 posts but i need 60 for each top tag. Please tell me how to iterate through the subquery.