販売されたアイテムの数を持つ 2 つのテーブルがあります。これら 2 つのテーブルを比較し、一致しないレコードを取得する必要があります。一方のテーブルで販売された商品の合計は、他方のテーブルで販売されたユニットの数量と等しくありません
select * from 
(select sum(units) AS UNITS, item, location, tran_date from tran_data_history where tran_date  = '' and tran_code = 1 group by item, location,tran_date)A,
(select sum(qty) AS QTY, item, store from sa_tran_item where  tran_Seq_no =''
)B
where A.item = B.item and A.location = B.store and A.UNITS <> B.QTY;
両方のテーブルでアイテムの数が一致しない行が表示されます。しかし、あるテーブルに存在し、別のテーブルには存在しないアイテム、ストアの組み合わせも必要です。
例: tran_data_history
item location units
11     a        5
22      b        1
33      c        4
sa_tran_item
item  store  qty
11      a     4
33      c      4
sa_tran_itemで、アイテム33が掲載されていない、行を表示したい
item  store  qty  units
11      a     4    5
22      b      0    1
助けてください