id val1 val2 val3 1 33 m k 1 32 m k 2 34 j v 4 47 h l
id val1 val2 val3 1 33 m k 2 34 j v 4 47 h l
WITH cte AS ( SELECT *, ROW_NUMBER() OVER (PARTITION BY id ORDER BY val1 DESC) AS rn FROM MyTable ) SELECT * FROM cte WHERE rn = 1
SELECT t1.<Field_List> FROM TableName1 AS t1 INNER JOIN ( SELECT MAX(val1) AS val1 FROM TableName1 ) AS t2 ON t1.id = t2.id AND t1.val1 = t2.val1
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)