Instant success: Users with highest-scored first answer

1

Please login or register to vote for this query.

(click on this box to dismiss)

Rank users by the score of their first answer ever posted on the site.

Code Review

Q&A for peer programmer code reviews

WITH UserFirstAnswer AS (
    SELECT OwnerUserId
         , MIN(Id) AS Id
        FROM Posts
        WHERE
            PostTypeId = 2 -- Answers
        GROUP BY OwnerUserId
)
SELECT TOP 200 RANK() OVER (ORDER BY Answers.Score DESC) AS [Rank]
     , Answers.Score
     , Users.Id AS [User Link]
     , Users.Reputation
     , Answers.Id AS [Post Link]
     , Answers.CreationDate AS [Date]
     , Question.Tags
    FROM Posts AS Answers
        INNER JOIN Posts AS Question
            ON Question.Id = Answers.ParentId
        INNER JOIN Users
            ON Users.Id = Answers.OwnerUserId
    WHERE Answers.Id IN (SELECT Id FROM UserFirstAnswer)
    ORDER BY Answers.Score DESC, Answers.OwnerUserId;

Enter Parameters

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