ID Name Date 1 name1 2011-02-15 00:00:00.000 2 name2 2011-02-15 00:00:00.000 3 name2 2011-02-15 00:00:00.000 4 name1 2011-02-15 00:00:00.000 5 name1 2011-02-15 00:00:00.000 6 name2 2011-02-15 00:00:00.000
select top 2 t.Name, t.Date from ( select row_number() over(partiton by name, date order by name, date desc) as rowno, Name, Date from MyTableNameHere ) as t where t.rowno=1
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)