oracle11g - sql to generate a column by manipulating previous row and previous column -
i have following in table
c1 1 4 3 2 2
i need generate c2 as:
c1 c2 1 1 4 5 3 8 2 10 2 12
the first row of c2 c1 row value. need add c1's 2nd row , c2's first row c2's second row.for third row of c2, c2= c1's third + c2's second , on...
i need in sql. possible?
i use oracle 11g.
your algorithm simplify running total:
create table c2 select c1 , sum(c1) on (order rowid) c2 c1;
the order issue - can't order null
. have used rowid
given example doesn't order c1
. if doing running total, must decided running against!
Comments
Post a Comment