Q&A for ebook publishers and readers
SELECT Tags.TagName, COUNT(DISTINCT Posts.Id) as QuestionCount, AVG(CAST(Posts.ViewCount as FLOAT)) as AvgViews, MAX(Posts.ViewCount) as MaxViews, COUNT(DISTINCT Posts.AcceptedAnswerId) as AcceptedAnswers FROM Posts LEFT JOIN PostTags ON Posts.Id = PostTags.PostId LEFT JOIN Tags ON PostTags.TagId = Tags.Id WHERE Posts.ViewCount > 1000 AND Posts.PostTypeId = 1 GROUP BY Tags.TagName ORDER BY AvgViews DESC;