Dear all,
I have two tables and I want to calculate the balance.
Table X ( record the product I sent to customer)
Customer------Product-----InQuantity
AAA------------A1-----------2
AAA------------A2-----------1
AAB------------A1-----------3
AAB------------A2-----------3
Table Z (recored the product which my customer can sell)
Customer-------Product--------OutQuantity
AAA--------------A1--------------1
AAB--------------A2--------------1
I want to query and want the result like this.
Balance
Customer------Product--------InQuantity--------OutQuantity-------Balance
AAA------------A1--------------2--------------------0-------------------2
AAA------------A2--------------1--------------------1-------------------0
AAB------------A1--------------3--------------------0-------------------3
AAB------------A2--------------3--------------------1-------------------2
I run the query with INNER JOIN , the result is correct but it miss some data. it shown only below.
AAA------------A2--------------1--------------------1-------------------0
AAB------------A2--------------3--------------------1-------------------2
I try to use the LEFT JOIN, but the result of Balance is not correct.
I do not know how to run query with the correct result
I will apprecitated for any advice.
Thank in advance
Attapol
I have two tables and I want to calculate the balance.
Table X ( record the product I sent to customer)
Customer------Product-----InQuantity
AAA------------A1-----------2
AAA------------A2-----------1
AAB------------A1-----------3
AAB------------A2-----------3
Table Z (recored the product which my customer can sell)
Customer-------Product--------OutQuantity
AAA--------------A1--------------1
AAB--------------A2--------------1
I want to query and want the result like this.
Balance
Customer------Product--------InQuantity--------OutQuantity-------Balance
AAA------------A1--------------2--------------------0-------------------2
AAA------------A2--------------1--------------------1-------------------0
AAB------------A1--------------3--------------------0-------------------3
AAB------------A2--------------3--------------------1-------------------2
I run the query with INNER JOIN , the result is correct but it miss some data. it shown only below.
AAA------------A2--------------1--------------------1-------------------0
AAB------------A2--------------3--------------------1-------------------2
I try to use the LEFT JOIN, but the result of Balance is not correct.
I do not know how to run query with the correct result
I will apprecitated for any advice.
Thank in advance
Attapol