Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Any way to do this in straight SQL?
Is it possible to use lag, but you don't know how many rows you want to go back?
create table history (
history_id number, history_sequence number, history_status varchar2(20), history_balance number); insert into history(1,123,'HISTORY 1',10); insert into history(1,128,'PROCESSED',0); insert into history(1,130,'PROCESSED',0);insert into history(1,131,'HISTORY 8',15); insert into history(1,145,'PROCESSED',0); for each history_id ordered by history_sequence loop
After this is run, I expect the values to be 1,123,'HISTORY 1',10 1,128,'PROCESSED',10 1,130,'PROCESSED',10
-- http://www.freelists.org/webpage/oracle-lReceived on Wed Dec 07 2005 - 15:13:34 CST
![]() |
![]() |