Returns the Users with the highest number of total views for their questions
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