I would go with plain old Group By (Peso's method as well). Here are the results from performance testing.--Generate some randomish data--500,000 RowsDrop Table #tmpCreate Table #tmp (col1 int, col2 int)Declare @cnt intSet @cnt = 0While @cnt < 100000 Begin Insert Into #tmp Select @cnt, @cnt % 5 * 10 Insert Into #tmp Select @cnt, @cnt % 6 * 20 Insert Into #tmp Select @cnt, @cnt % 7 * 30 Insert Into #tmp Select @cnt, @cnt % 8 * 40 Insert Into #tmp Select @cnt, @cnt % 9 * 50 Set @cnt = @cnt + 1End--PesoSELECT Col1, Max(Col2) FROM #tmp GROUP BY Col1 ORDER BY Col1/*SQL Server parse and compile time: CPU time = 0 ms, elapsed time = 23 ms.(100000 row(s) affected)Table '#tmp'. Scan count 3, logical reads 1104, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.SQL Server Execution Times: CPU time = 719 ms, elapsed time = 1416 ms.*/--visakh16SELECT t.Col1,t.Col2FROM( SELECT ROW_NUMBER() OVER(PARTITION BY Col1 ORDER BY Col2 DESC) AS RowNo, Col1, Col2 FROM #tmp) tWHERE t.RowNo = 1ORDER BY Col1/*SQL Server parse and compile time: CPU time = 0 ms, elapsed time = 21 ms.(100000 row(s) affected)Table '#tmp'. Scan count 3, logical reads 1104, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.SQL Server Execution Times: CPU time = 1545 ms, elapsed time = 2387 ms.*/