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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generate Cummulative Total in Access

Status
Not open for further replies.

adventurous1

Programmer
Mar 5, 2004
64
0
0
US
Hi... I am hoping someone smart can help me with this...

I have records like this:

Type Team Time Period Date #Bugs
Auto Accounting Year 1/2/09 10
Auto Applications Year 1/2/09 30
Auto Finance Year 1/2/09 5
Auto Cust Service Year 1/2/09 11
Auto Accounting Year 1/3/09 6
Auto Applications Year 1/3/09 4
Auto Finance Year 1/3/09 2
Auto Cust Service Year 1/3/09 8

And I need the following result to include a cummulative total:

Type Team Time Period Date #Bugs Cumm_Bugs
Auto Accounting Year 1/2/09 10 10
Auto Applications Year 1/2/09 30 30
Auto Finance Year 1/2/09 5 5
Auto Cust Service Year 1/2/09 11 11
Auto Accounting Year 1/3/09 6 16
Auto Applications Year 1/3/09 4 32
Auto Finance Year 1/3/09 2 7
Auto Cust Service Year 1/3/09 8 19


Can someone help me with a function that can do this?

Thanks!
 
Something like this ?
Code:
SELECT A.Type, A.Team, A.[Time Period], A.Date, A.[#Bugs], Sum(B.[#Bugs]) AS Cumm_Bugs
FROM yourTable AS A INNER JOIN yourTable AS B
ON A.Type=B.Type AND A.Team=B.Team AND A.[Time Period]=B.[Time Period] AND A.Date>=B.Date
GROUP BY A.Type, A.Team, A.[Time Period], A.Date, A.[#Bugs]
ORDER BY 4, 2

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
On looking through the results, this does NOT work. If the time period is not contiguous (i.e. 1/1, 1/2, 1/3 then a gap, 1/5, 1/6, 1/9, etc. the counts do not sum correctly).

Can someone please help?

Thanks!
 
It looks to me like the query by PHV does work, even with time period gaps. Could you give an example of data that doesn't seem to work, and the result you're expecting?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top