How to get top 1 record of each group in sql? Ask Question
;WITH cte AS
(
SELECT *,
ROW_NUMBER() OVER (PARTITION BY ID ORDER BY Date DESC)
AS rn
FROM Table
)
SELECT *
FROM cte
WHERE rn = 1
Enter an email address to invite a colleague or co-author to join you on socimo. They will receive an email and, in some cases, up to two reminders.