Tags average views (with threshold for tag questions amount)

1

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

DECLARE @TagThreshold int = ##TagThreshold##

SELECT t.TagName, SUM(p.ViewCount) AS Views, SUM(p.ViewCount) / COUNT(*) AS [Avg Views]
  FROM Posts p 
JOIN PostTags pt
  ON p.Id = pt.PostId
JOIN Tags t
  ON pt.TagId = t.id
WHERE t.Count > @TagThreshold
GROUP BY t.TagName 
--ORDER BY t.TagName
--ORDER BY [Views] DESC
ORDER BY [Avg Views] DESC

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results