Users with the highest average score per post

1

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

-- MinPosts: Include only users with at least this many posts:
WITH scoreByPost AS (
    SELECT
                p.OwnerUserId,
                COUNT (p.Id) AS PostCount,
                AVG (CAST (p.Score AS FLOAT) ) AS AverageScore
    FROM
                Posts p
    GROUP BY    p.OwnerUserId
)
SELECT      TOP 1000 -- Full table keeps timing out on SO data.
            u.Id    AS [User Link],
            u.Reputation,
            FORMAT (sbp.AverageScore, '#,###,##0.000') AS [Average Score]
FROM        scoreByPost sbp
INNER JOIN  Users u
ON          u.Id = sbp.OwnerUserId
WHERE       sbp.PostCount >= ##MinPosts:INT?10##
ORDER BY
            sbp.AverageScore    DESC,
            sbp.PostCount       DESC

Enter Parameters

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