各テーブルでサブクエリを実行して、各顧客の合計数量を取得し、顧客ide.g
によって結果を結合できます。SELECT a.*, b.*
FROM (
Select customer_id, product, dateofsale, PayMeth1, PayMeth2, SUM(Qty) as Qty
from TableA
Group by customer_id, product, dateofsale, PayMeth1, PayMeth2
) a
JOIN (
Select customer_id, product, dateofsale, PayMeth1, PayMeth2, SUM(Qty) as Qty
from TableB
Group by customer_id, product, dateofsale, PayMeth1, PayMeth2
) b
ON a.customer_id = b.customer_id