Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Update current row from the results from previous row - response (2) by dnoeth

$
0
0

Calculate the values in an UPDATE FROM:

SELECT seq_no, num, SUM_FROM_PREV_REC,
   COALESCE(SUM(SUM_FROM_PREV_REC) 
   OVER (ORDER BY seq_no
         ROWS UNBOUNDED PRECEDING),0) +
   COALESCE(SUM(num) 
   OVER (ORDER BY seq_no
         ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING), 0)
FROM tab

 


Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>