Most recent comments from given set of users

1

Please login or register to vote for this query.

(click on this box to dismiss)

Physical Fitness Meta

Q&A about the site for physical fitness professionals, athletes, trainers, and those providing health-related needs

;  with recent_cte as
(
select
    u.Id,
    MAX(c.Id) AS MaxId
FROM Users u INNER JOIN Comments c ON c.UserId=u.Id
WHERE u.Id IN (##list##)
GROUP BY u.Id
)

SELECT c.UserId AS [User Link], MaxId AS [Comment Link], c.CreationDate, c.Score,
  url = 'site://users/' + CAST(c.UserId AS varchar) + '?tab=activity&sort=comments'
FROM recent_cte inner JOIN Comments c ON MaxId = c.Id
ORDER BY c.CreationDate DESC

Enter Parameters

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