SQL: getting the max value of one column and the corresponding other columns [duplicate]

Use ROW_NUMBER() :

SELECT s.id,s.tag,s.version FROM (
    SELECT t.*,
           ROW_NUMBER() OVER(PARTITION BY t.id ORDER BY t.version DESC) as rnk
   FROM YourTable t) s
WHERE s.rnk = 1

Leave a Comment