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

Running sum in UPDATE query

Status
Not open for further replies.

teach314

Technical User
Jul 29, 2011
183
CA
hi - I have a loop that generates a large series of query results. Here are three typical outputs. I have added spaces to line up equal values of ID:

Code:
ID    Freq               ID    Freq               ID    Freq           etc... 
                         51      6                51      2
                         53     18        
55       3               55     67                55     19
56      12                                        56    346
59     211               59     45                59    129
60      99               60     17                60     29
63      11                                        63      4

I want to use an UPDATE query to keep a running sum vaules of Freq each time the query is run. the final output for the three query results above would be:

Code:
ID    Freq
51      8
53     18
55     89
56    358
59    385  
60    145 
63     15

{/code]
could somebody show me how to handle the summing in the Freq column.

thanks
 
I'm wondering... would it not be best to build a query that just calculates all your sums whenever you need them rather than appending to a table that just stores sums? It just seems like a bad idea to me. But maybe I'm missing something.

When you say the "running total"... how do you determine the different boxes/sums you want to have... is it based on day/week/month/year, or something like that? Or is it grouped on some other value/field? If it's grouped on anything, you can just build a query that gives you a summary of everything whenever you need it rather than building another table.

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
yes, you are right. I tried it that way and it is a much better approach. thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top