Tags ordered by average views

0

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 @TagThresold int = ##TagThresold##

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 > @TagThresold
GROUP BY t.TagName 
ORDER BY [Avg Views] DESC

Enter Parameters

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