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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -