Best way to perform this select -
03-20-2006
, 09:17 AM
Hello all,
I have similar table:
amounts
id int, row_dt datetime, amount int
it contains
id row_dt amount
1 2005-01-01 300
1 2006-02-30 500
2 1998-09-01 900
etc
I need to update another table for every id only those lines where
row_dt is newwest.
My query looks similar to this:
update anothertab
set current_amount=amount
from anothertab t, amounts a
where t.id=a.id
and a.row_dt=(select max(row_dt) from amounts a2 where a2.id=a.id)
Do you thing it is the best approach?
Thanks for your comments...
Jarda |