Sum based on repeating field (1 Viewer)

HotelierDream

New member
Local time
Today, 04:18
Joined
Dec 27, 2020
Messages
15
I am going to try and make this make sense but I cannot promise it will....

I have a table that has transactions on it, there are fields Month, TransCode, TransDesc, Qty, GrossAmt.

The TransCode,TransDesc and Month fields repeat as it is just a list of all entries for the month.

I want to make a query that will take the items and summarize them and amend the entry to a new table...

In example
MonthTransCodeTransDescQTYGrossAMT
December10000Food5500
December10000Food4400
December10000Food2200


Would become: (On the other table)
MonthTransCodeTransDescQTYGrossAMT
December10000Food111100
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:18
Joined
Oct 29, 2018
Messages
21,454
Hi. Welcome to AWF!

You could try using a Totals query. For example,

SELECT [Month], TransCode, TransDesc, Sum(Qty), Sum(GrossAMT)
FROM TableName
GROUP BY [Month], TransCode, TransDesc
 

HotelierDream

New member
Local time
Today, 04:18
Joined
Dec 27, 2020
Messages
15
I could swear I tried it earlier and It didnt work.... now it did. Access is mocking me! LOL

Thank you so much!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:18
Joined
Oct 29, 2018
Messages
21,454
I could swear I tried it earlier and It didnt work.... now it did. Access is mocking me! LOL

Thank you so much!
Hi. Glad to hear you got it sorted out. Good luck with your project.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 04:18
Joined
Feb 28, 2001
Messages
27,140
The only thing you said that was perhaps not quite right was this: If instead of "Month" you had the actual date, you could skip updating another table with what is essentially duplicated data. You could have the query look at your date field and use the DatePart functions to build whatever kind of date information you needed. Which would include doing your summary/rollup for any month on record.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:18
Joined
Feb 19, 2002
Messages
43,223
I realize your question was answered but the solution is incorrect.
1. If your transactions are really marked only by month, you're going to have a big problem come January.
2. It is not necessary to save the summarized data to a new table. What are you going to do next month? Any time you want the summary, just run a query.
 

Users who are viewing this thread

Top Bottom