Average reputation of users depending on number of posts

1

Please login or register to vote for this query.

(click on this box to dismiss)

Mathematics

Q&A for people studying math at any level and professionals in related fields

---by changing mult you decide how the users are divided into groups
---for example, if mult=10, we're looking at users with 0 to 9 posts, users with 10 to 19 posts, etc.
;with postgroups_cte AS (
SELECT
  u.Id AS uid,
  u.Reputation AS rep,
  CAST(COUNT(p.Id)/##mult?100## AS int) AS pgroup
  FROM Users u INNER JOIN Posts p ON p.OwnerUserId=u.Id
  GROUP BY u.Id, u.Reputation
)

SELECT
  pgroup,
  AVG(CAST(rep AS decimal)) AS Average
FROM postgroups_cte
GROUP BY pgroup
ORDER BY pgroup DESC

Enter Parameters

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