CCIDBMNG
Registered User.
- Local time
- Today, 14:47
- Joined
- Jan 25, 2002
- Messages
- 154
I have two identical tables in my database and I need to do a sum of certain records from both tables so I created a union query to pull the information from the two tables. Now I need to do a sum of the records from the union query. I know that I can create a seperate query to look at the union query and do the sum in there but what I was wondering is if there is a way to sum up the records from both tables in the union query.
For example the fields in both tables are invoice number, product 1, and product 2. So my union query looks like this
SELECT InvoiceNum, sum([product1]) as Prod1Ttl, sum([product2] as Prod2Ttl from table1
UNION
SELECT InvoiceNum, sum([product1]) as Prod1Ttl, sum([product2] as Prod2Ttl from table2
This displays 2 rows in the results of the union query now I need to do an overall sum of the two products. Can I do this in the union query or do I need to create a select query to sum those up?
Any input would be greatly appreciated. Thanks.
For example the fields in both tables are invoice number, product 1, and product 2. So my union query looks like this
SELECT InvoiceNum, sum([product1]) as Prod1Ttl, sum([product2] as Prod2Ttl from table1
UNION
SELECT InvoiceNum, sum([product1]) as Prod1Ttl, sum([product2] as Prod2Ttl from table2
This displays 2 rows in the results of the union query now I need to do an overall sum of the two products. Can I do this in the union query or do I need to create a select query to sum those up?
Any input would be greatly appreciated. Thanks.