Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to update columns with the value other rows at the same table

mail8mzSep 17 2012 — edited Sep 17 2012
Hello,

I am using Oracle 11.2, I would like to use SQL to update one column based on values of other rows at the same table. Here are the details:

create table TB_test (myId number(4), crtTs date, updTs date);

insert into tb_test(1, to_date('20110101', 'yyyymmdd'), null);
insert into tb_test(1, to_date('20110201', 'yyyymmdd'), null);
insert into tb_test(1, to_date('20110301', 'yyyymmdd'), null);
insert into tb_test(2, to_date('20110901', 'yyyymmdd'), null);
insert into tb_test(2, to_date('20110902', 'yyyymmdd'), null);

After running the SQL, I would like have the following result:

1, 20110101, 20110201
1, 20110201, 20110301
1, 20110301, null
2, 20110901, 20110902
2, 20110902, null

Thanks for your suggestion.
This post has been answered by odie_63 on Sep 17 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 15 2012
Added on Sep 17 2012
5 comments
5,367 views