create table test(i number , j number);
insert into test values(1,2)
insert into test values(1,3)
insert into test values(1,4)
select * from test;
I J
---------- ----------
1 2
1 3
1 4
My intentions:
after update
select * from test;
I J
---------- ----------
1 2
1 3+2
1 4+3
after
select * from test;
I J
---------- ----------
1 2
1 5+2
1 7+5
In oracle,I use this:
update test x
set x.j = x.j + (select lag_j
from (select i, j, nvl(lag(j) over (order by i,j) ,0) as lag_j
from test) y
where x.i = y.i and x.j = y.j)
how can translate this for work in postgres?
Thanks's
Paul