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!

Need help in a Query to compare previous and next value

TinaNov 2 2016 — edited Nov 2 2016

Hi Gurus,

    I have a table where we have data which looks like below which is sorted in an order already.

    This is something historical table which gives various status of a column a (which initially had status 9000, then 9001, 9004 and 9005).

    I am trying to find out all the values of column 'a' in entire table, for which status moved from '9004' to '9005'.

    Both 100 and 200 goes from  'previous status' 9004 to 'next status' 9005.

    Is there any way to list the values?

create table my_tab (a number, b number );


insert into my_tab values(100, 9000);
insert into my_tab values(100, 9001);
insert into my_tab values(100, 9004);
insert into my_tab values(100, 9005);

insert into my_tab values(200, 9002);
insert into my_tab values(200, 9002);
insert into my_tab values(200, 9004);
insert into my_tab values(200, 9005);

commit;

This post has been answered by Frank Kulash on Nov 2 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 30 2016
Added on Nov 2 2016
4 comments
775 views