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

Motor Vehicle Maintenance and Repair Meta

Q&A about the site for mechanics and DIY enthusiast owners of cars, trucks, and motorcycles

-- 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 main site
loading Hold tight while we fetch your results