displaying based on latest date and second latest date
407048Sep 17 2007 — edited Sep 18 2007Oracle 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?