SQL> create table scott.tab as
2 (select 1 a, 0 b,0 c, 0 d
3 from dual
4 union all
5 select 1 a, 10 b,0.5 c, 0 d
6 from dual
7 union all
8 select 1 a, 20 b,1.5 c, 0 d
9 from dual
10 union all
11 select 2 a, 0 b,0 c, 0 d
from dual
12 13 union all
14 select 2 a, 10 b,1 c, 0 d
15 from dual
union all
16 17 select 2 a, 10 b,2 c, 0 d
18 from dual
19 )
/
20
SQL> update scott.tab t1
set d =
(select lag_c
from
( select rowid, lag(c,1,0) over (partition by a order by b, c) + c lag_c
from scott.tab)
where rowid = t1.rowid
)
/
6 Zeilen wurden aktualisiert.
SQL> select * from scott.tab
2 /
A B C D
---------- ---------- ---------- ----------
1 0 0 0
1 10 ,5 ,5
1 20 1,5 2
2 0 0 0
2 10 1 1
2 10 2 3
6 Zeilen ausgewählt.
SQL>
|