Users with highest number of combined Views

4

Please login or register to vote for this query.

(click on this box to dismiss)

Returns the Users with the highest number of total views for their questions

Economics

Q&A for those who study, teach, research and apply economics and econometrics

-- Users with highest number of combined Views
-- Returns the Users with the highest number of total views for their questions

DECLARE @total float

SELECT @total = Sum(ViewCount) FROM Posts WHERE PostTypeId = 1

SELECT 
  Users.Id AS [User Link],
  Sum(ViewCount) AS TotalViews,
  Count(*) AS NumberOfQuestions,
  Sum(ViewCount)/Count(*) AS AvgViewsPerQuestion,
  100 * Sum(ViewCount) / @total AS PercentOfSite
FROM Posts 
INNER JOIN Users ON Users.Id = Posts.OwnerUserId 
WHERE PostTypeId = 1 
GROUP BY Users.Id 
ORDER BY TotalViews DESC

Enter Parameters

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