14,494 questions
Hi @Y.N If I understand right, you could use Row_number here.
Check this:
SELECT ID,col1,col2
FROM (SELECT *,ROW_NUMBER()OVER(PARTITION BY ID ORDER BY col1 DESC)AS RNum FROM #demo)S
WHERE S.RNum=1
Best regards, Cosmog Hong