My top 10 Posts with highest score for Comments
Q&A for SharePoint enthusiasts
-- My top 10 Posts with highest score for Comments -- My top 10 Posts with highest score for Comments DECLARE @UserId int = ##UserId## SELECT TOP 10 a.Score, a.PostId as [Post Link] FROM (SELECT *, row_number() over(partition BY PostId ORDER BY Score) cn FROM Comments WHERE UserId = @UserId )a WHERE cn = 1 ORDER BY score DESC