Askan,
this shud work:
--Method 1
select id,name,date
from
(
select id,name,date,row_number() over(partition by name order by date desc) rnum
from #temp
) tt
where tt.rnum=1
--Method 2
select t.*
from #temp t
inner join (
select name,max(date) date
from #temp
group by name) tt on t.name=tt.name and t.date=tt.date
order by t.id
--Method 3
select a.*
from #temp a
left join #temp b on a.date<b.date and a.name=b.name
where b.id is NULL
Thanks,
Jay
<If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>