dbTalk Databases Forums  

Best way to perform this select

comp.databases.sybase comp.databases.sybase


Discuss Best way to perform this select in the comp.databases.sybase forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jaroslav
 
Posts: n/a

Default 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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.