Users with Max Reputation by N number of posts


Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

-- maxRows: How many rows to return:
-- maxPosts: Maximum number of posts a user can have:

SELECT TOP ##maxRows:INT?100##
            'site://u/' + CAST(u.Id AS NVARCHAR) + '|' + u.DisplayName  AS [User]
            , u.Reputation
            , COUNT (p.Id)  AS [Post Count]
FROM        Users u
LEFT JOIN   Posts p         ON (p.OwnerUserId = u.Id  AND  p.PostTypeId IN (1, 2) )  -- Q & A only
WHERE       u.Reputation > 15  -- Speed things up by culling low-rep users
GROUP BY    u.Id
            , u.DisplayName
            , u.Reputation
HAVING      COUNT (p.Id) <= ##maxPosts:INT?10##
ORDER BY    u.Reputation DESC
            , [Post Count]
            , u.DisplayName

Enter Parameters

Switch sites:
loading Hold tight while we fetch your results