Sum 2 quantity in 2 tables

  • Thread starter roystonteo via AccessMonster.com
  • Start date
R

roystonteo via AccessMonster.com

Dear All,

Currently i have these:
Table A: Part No, Open Quantity
Table B: Part No, In Quantity
Table C: Part No, Out Quantity

I need to have 2 queries:
1st) how do i sum Open Quantity and In Quantity?
2nd) how do i get the balance quantity? which is sum open quantity + IN
quantity minus OUT quantity

Please advise me.

Thank you
 
P

pietlinden

Dear All,

Currently i have these:
Table A: Part No, Open Quantity
Table B: Part No, In Quantity
Table C: Part No, Out Quantity

I need to have 2 queries:
1st) how do i sum Open Quantity and In Quantity?
2nd) how do i get the balance quantity? which is sum open quantity + IN
quantity minus OUT quantity

Please advise me.

Thank you

union the two tables in a query then do a sum on your union query.
 
P

pietlinden

Dear All,

Currently i have these:
Table A: Part No, Open Quantity
Table B: Part No, In Quantity
Table C: Part No, Out Quantity

I need to have 2 queries:
1st) how do i sum Open Quantity and In Quantity?
2nd) how do i get the balance quantity? which is sum open quantity + IN
quantity minus OUT quantity

Please advise me.

I would actually merge all the tables and include a field to hold the
type of each record {Open, In, Out}. Then you can use indexes and all
that. Will work MUCH faster than union queries. And your queries
become trivial. Create a totals query to sum IN, OUT, Open and then
use another query to do the simple math.that adds the totals.
 
R

roystonteo via AccessMonster.com

Hi Piet,

But if Table A and Table B has the same part number and quantity, the union
will not total this 2 up.
If Table A + B, the query is UNION SELECT quantity *1 or Select quantity. Am
i right?
For subtraction, the union select quantity *-1

Table A: Part No, Open Quantity
Table B: Part No, In Quantity



Dear All,
[quoted text clipped - 9 lines]
Please advise me.

I would actually merge all the tables and include a field to hold the
type of each record {Open, In, Out}. Then you can use indexes and all
that. Will work MUCH faster than union queries. And your queries
become trivial. Create a totals query to sum IN, OUT, Open and then
use another query to do the simple math.that adds the totals.
 

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

Similar Threads

Multiple Dates in a table 1
Sum of Table 2
Sum of 3 Tables 5
In and out qty 3
Multiple IIF query 1
I Combined 2 queries, but some records were missing. 6
monthly quantity report 4
unexpected query result 4

Top