I have wrecked my brain on this problem for quite some time. I\'ve also reviewed other questions but was unsuccessful.
The problem I have is, I have a list of results/t
TSQL:
declare @R table
(
Registration varchar(16),
ID int,
Date datetime,
UnitType varchar(16)
)
insert into @R values ('A','1','20090824','A')
insert into @R values ('A','2','20090825','B')
select R.Registration,R.ID,R.UnitType,R.Date from @R R
inner join
(select Registration,Max(Date) as Date from @R group by Registration) M
on R.Registration = M.Registration and R.Date = M.Date
This can be inefficient if you have thousands of rows in your table depending upon how the query is executed (i.e. if it is a rowscan and then a select per row).