I have inherited a table with a structure something like this:
ID Name Timestamp Data ---------------------------- 1 A 40 ... 2 A
SQL Server 2005 (onwards):
WITH MostRecentRows AS ( SELECT ID, Name, Data, ROW_NUMBER() OVER (PARTITION BY Name ORDER BY TimeStamp DESC) AS 'RowNumber' FROM MySchema.MyTable ) SELECT * FROM MostRecentRows WHERE RowNumber = 1