Ident / A / B / val
1. 1. 1. 200
2. 1. 1. 250
3. 1. 1. 180
4. 1. 2. 15
5. 1. 2. 10
DECLARE @VAL TABLE ( Ident INT, A INT, B INT, val INT );
INSERT @VAL VALUES
( 1, 1, 1, 200 ),
( 2, 1, 1, 250 ),
( 3, 1, 1, 180 ),
( 4, 1, 2, 15 ),
( 5, 1, 2, 10 );
SELECT *
FROM @VAL
INNER JOIN ( SELECT MAX(Ident) AS MIdent
FROM @VAL
GROUP BY A, B ) AS MaxIndent
ON MaxIndent.MIdent = Ident