Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need SQL to calculate Running Sum in Oracle

Status
Not open for further replies.

anedra

Programmer
Jul 26, 2005
1
US
Hi,

I'm looking for SQL examples to calculate the running sum in Oracle:
Activity Running Sum
Account100 50.00 50.00
Account200 75.00 125.00
Account300 25.00 150.00

The Account information is stored in a typical dimension table and the activity is stored in a Fact table. How might I calculate the running Sum column?

Thanks,
Anedra
 
Use a summary column, as a 'sum', in the same group as your amount column and reset it at report level.
 
You may also consider analytic variant of sum function:

Code:
select 
  activity, 
  amount, 
  sum(amount) over (ORDER BY activity) cumulative
from activities


Regards, Dima
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top