我有两张桌子,上面有售出物品的数量。我需要比较这两个表并获取不匹配的记录,一个表中售出的商品总和不等于另一表中售出的单位数量
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
请帮忙