Comments with highest score

1

Please login or register to vote for this query.

(click on this box to dismiss)

This ranks the top 100 comments on the site. Note: can also be filtered to the top 100 comments of a certain user, if an ID is provided. Leave default '0' for 'all' comments.

Stack Overflow

Q&A for professional and enthusiast programmers

--User: User ID to Rank: "Enter 0 if you want to rank ALL users, otherwise enter your own ID"
DECLARE @UserID int = ##User:int?0##;

SELECT TOP 100 
RANK() OVER (ORDER BY C.Score DESC) AS Rank,
C.Id AS [Comment Link],
U.Id AS [User Link],
C.Score,
C.PostId AS [Post Link],
C.CreationDate AS [Comment Date]
FROM Comments C
  INNER JOIN Users U
    ON C.UserId = U.Id
WHERE (U.Id = @UserID OR NULLIF(@UserID, 0) IS NULL)
ORDER BY C.Score DESC

Enter Parameters

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