Home > Archive > Sybase Database > March 2006 > Best way to perform this select









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Best way to perform this select
Jaroslav

2006-03-21, 3:23 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=amoun
t
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

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com