Q&A for scientific skepticism
-- For each question (i.e. posts where type = question), count the total -- number of tags – do this only for posts that have more than 5 tags associated -- with them. Display 10 random posts with the highest number of tags. SELECT TOP 10 Posts.Id, Title, COUNT(PostTags.PostId) AS TagCount FROM PostTypes INNER JOIN Posts ON (PostTypes.Id = Posts.PostTypeId) INNER JOIN PostTags ON (Posts.Id = PostTags.PostId) WHERE PostTypes.Name = 'Question' AND (SELECT COUNT(*) FROM PostTags WHERE PostId = Posts.Id) = 5 GROUP BY Posts.Id, Title ORDER BY TagCount DESC, NEWID();