3
我有兩個表StockOutward和產品outward..I必須獲取總和(數量),不是等於總結(數量)stockOutward ..如何比較兩個SQL查詢值
StockOutward
Id ProductId Qty Location Orderid 1 7 2 2 38 2 8 1 2 38 3 7 1 2 38
ProductOutward
Id ProductId Qty Location Orderid 1 7 12 2 38 2 8 1 2 38
我需要從stockoutward輸出作爲產品編號7
我用下面的查詢
Select
sum(qty) as Qty,ProductId
from
StockOutward
where
Orderid='38'
group by
ProductId
Union
Select
sum(qty) as Qty,
ProductId
from
ProductOutward
where
Orderid='38'
group by
ProductId
謝謝,我會測試和說@ wewesthemenace – Priya