Home » SQL & PL/SQL » SQL & PL/SQL » Cummulative SUM
Cummulative SUM [message #19020] Tue, 26 February 2002 03:49 Go to next message
ajay
Messages: 45
Registered: December 2000
Member
In a table I have two columns A and B ,
numeric values for A are populated by some program.
I have to populate the column B so that for each row, column B will hold the cummulative sum of A for all rows above it.
e.g
A | B
1 | 1
1 | 2
9 | 11
0 | 11
1 | 12

etc

what is the easiest and fastest way of doing this.
Thanks in advance .
Ajay
Re: Cummulative SUM [message #19021 is a reply to message #19020] Tue, 26 February 2002 03:53 Go to previous message
Suresh Vemulapalli
Messages: 624
Registered: August 2000
Senior Member
SELECT A, sum (A) OVER
(order by A RANGE BETWEEN rownum PRECEDING AND CURRENT ROW) AS B
FROM table1
Previous Topic: Stand By Server
Next Topic: triggers
Goto Forum:
  


Current Time: Sat Apr 20 01:41:08 CDT 2024