Good day,
I have the following two tables:
tbl_transactionlist
DOC_NR | TRANS_TYPE | SITE | TRANS_DATE
000001 | DELIVERY | PRO1 | 14/02/2017
000002 | DELIVERY | PRO1 | 15/02/2017
000003 | RETURN | PRO1 | 16/02/2017
tbl_transactions
TRANS_NR | DOC_NR | ITEM_CODE | QUANTITY
PRO2017-01 | 000001 | 030801 | 2
PRO2017-02 | 000001 | 030802 | 3
PRO2017-03 | 000002 | 030801 | 2
PRO2017-04 | 000003 | 030801 | 1
Now, I have a 2 x Queries to return the sum of all the deliveries / returns per site and per item_code.
This is the result:
qry_activedeliveries
SITE | ITEM_CODE | QUANTITY
PRO1 | 030801 | 4
PRO1 | 030802 | 3
qry_activereturns
SITE | ITEM_CODE | QUANTITY
PRO1 | 030801 | 1
Now, I need a query to do:
(qry_acctivedeliveries).quantity - (qry_activereturns).quantity
The result should look as follows:
SITE | ITEM_CODE | QUANTITY
PRO1 | 030801 | 3
PRO1 | 030802 | 3
However, it is pulling through item code "030802" as QTY = 0. I think it is subtracting the return note 000001 from both item_codes.
Please assist?
I upload the database as well so you can see.View attachment Prota Services Material Capture Sheet.zip
I have the following two tables:
tbl_transactionlist
DOC_NR | TRANS_TYPE | SITE | TRANS_DATE
000001 | DELIVERY | PRO1 | 14/02/2017
000002 | DELIVERY | PRO1 | 15/02/2017
000003 | RETURN | PRO1 | 16/02/2017
tbl_transactions
TRANS_NR | DOC_NR | ITEM_CODE | QUANTITY
PRO2017-01 | 000001 | 030801 | 2
PRO2017-02 | 000001 | 030802 | 3
PRO2017-03 | 000002 | 030801 | 2
PRO2017-04 | 000003 | 030801 | 1
Now, I have a 2 x Queries to return the sum of all the deliveries / returns per site and per item_code.
This is the result:
qry_activedeliveries
SITE | ITEM_CODE | QUANTITY
PRO1 | 030801 | 4
PRO1 | 030802 | 3
qry_activereturns
SITE | ITEM_CODE | QUANTITY
PRO1 | 030801 | 1
Now, I need a query to do:
(qry_acctivedeliveries).quantity - (qry_activereturns).quantity
The result should look as follows:
SITE | ITEM_CODE | QUANTITY
PRO1 | 030801 | 3
PRO1 | 030802 | 3
However, it is pulling through item code "030802" as QTY = 0. I think it is subtracting the return note 000001 from both item_codes.
Please assist?
I upload the database as well so you can see.View attachment Prota Services Material Capture Sheet.zip