Amalgamate tables

S

sam

Hi all,
I have a query problem that has puzzled me all
morning.
I have two tables: Invoices and Receipts. I am
using two fields Batch_number and amount (this is the sum
for each batch). What I need is to amalgamate them in some
way. For instance I want to bring them together and where
there is a common Batch_number add it.
Hope I've explained this ok!
Thanks
Sam
 
M

Michel Walsh

Hi,


Access 2000 or more recent:

SELECT BatchID, SUM( amount )

FROM ( SELECT batchID, amount FROM receipts
UNION ALL
SEELCT batchID, - amount FROM invoices ) As a

GROUP BY BatchID



For Access 97, make a save query with the UNION ALL query, and use

SELECT BatchID, SUM(amount)
FROM mySavedQuery
GROUP BY BatchID


rather that the virtual table as illustrated here up.




Hoping it may help,
Vanderghast, Access MVP
 

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