Cumulative sum

H

hrskinn

I a query that collects the requried data into period buckets.
Now I need to be able to cumulative sum.
So Peroid 1 equals period 1,
Period 2 equals Period 1 + 2
Period 3 equals Period 1+2+3
and so on..

Any ideas on how to create a cumulative sum querey or is there another way
that is more efficent?
Harold

PERIOD REC_RTL DEPT
1 $25.00 10
2 $26.00 10
3 $27.00 10
 
J

Jeff Boyce

Use the query to return the amounts-per-period.

Use a report to show amount-per-period and running-sum. You can add a
control to the report and turn on that control's running sum property.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
M

Marshall Barton

hrskinn said:
I a query that collects the requried data into period buckets.
Now I need to be able to cumulative sum.
So Peroid 1 equals period 1,
Period 2 equals Period 1 + 2
Period 3 equals Period 1+2+3
and so on..

Any ideas on how to create a cumulative sum querey or is there another way
that is more efficent?
Harold

PERIOD REC_RTL DEPT
1 $25.00 10
2 $26.00 10
3 $27.00 10


SELECT T.Period, T.REC_RTL, T.DEPT,
(SELECT Sum(X.REC_RTL)
FROM qry As X
WHERE X.Period <= T.Period) As RunSum
FROM qry As X

But this is far easier/faster in a report where you can just
use a text box bound to the REC_RTL field with its
RunningSum property.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top