LAST_VALUE suggestion
petezAug 11 2010 — edited Nov 2 2010Hi Guys,
How to modify LAST_VALUE call in query
select t.*, last_value( order_val) over(order by order_date) from testx t
to get 12 for dates 7/1/2010, 8/1/2010, 9/1/2010
ID ORDER_DATE ORDER_VAL LAST_VALUE(ORDER_VAL)OVER(ORDE
1 1/1/2010 3 3
2 2/1/2010 5 5
3 3/1/2010 7 7
4 4/1/2010 8 8
5 5/1/2010 9 9
6 6/1/2010 12 12
7 7/1/2010 12
8 8/1/2010 12
9 9/1/2010 12
(Ora 9.2):
create table testx ( id number, order_date date, order_val number );
insert into testx values ( 1, to_date('2010-01-01','yyyy-mm-dd'), 3 );
insert into testx values ( 2, to_date('2010-02-01','yyyy-mm-dd'), 5 );
insert into testx values ( 3, to_date('2010-03-01','yyyy-mm-dd'), 7 );
insert into testx values ( 4, to_date('2010-04-01','yyyy-mm-dd'), 8 );
insert into testx values ( 5, to_date('2010-05-01','yyyy-mm-dd'), 9 );
insert into testx values ( 6, to_date('2010-06-01','yyyy-mm-dd'), 12 );
insert into testx values ( 7, to_date('2010-07-01','yyyy-mm-dd'), null );
insert into testx values ( 8, to_date('2010-08-01','yyyy-mm-dd'), null );
insert into testx values ( 9, to_date('2010-09-01','yyyy-mm-dd'), null );
Thanks,
Regards,
Piotr