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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

displaying based on latest date and second latest date

407048Sep 17 2007 — edited Sep 18 2007
Oracle 10.2.0.3 on solaris :
I have a history table(say ORDERS_HIST) with 3 fields : CODE, DATE and VALUE
The data is as follows :
CODE DATE VALUE
ABD 09/15/2007 23
ABD 09/16/2007 54
ABD 09/17/2007 22
KLO 01/01/2007 72
KLO 04/20/2007 89
KLO 04/21/2007 91

Each code can have multiple records
ABD code value was changed from 23 to 54 and then to 22 on the given dates.

I needed to display in my result set :

ABD 22 54
KLO 91 89

In other words, the most recent value and the second recent value(based on date) is what I am trying to display
Can this be done using a SELECT and if so, how?

Comments

Processing
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 16 2007
Added on Sep 17 2007
4 comments
10,041 views