Total question views by user reputation

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

WITH ViewTotals AS (SELECT u.Reputation,
  SUM(CAST(p.ViewCount AS BIGINT)) AS ViewCount
  FROM Posts AS p
  INNER JOIN Users AS u ON p.OwnerUserId = u.Id
  WHERE p.PostTypeId = 1
  GROUP BY u.Reputation)
SELECT v1.Reputation, SUM(v2.ViewCount)
  FROM ViewTotals AS v1
  INNER JOIN ViewTotals AS v2
    ON v1.Reputation >= v2.Reputation
  GROUP BY v1.Reputation
  ORDER BY v1.Reputation

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results