【发布时间】:2015-06-05 04:51:40
【问题描述】:
我有两个表 StockOutward 和产品 outward..我必须获取不等于 sum(qty) stockOutward 的 sum(qty)..
StockOutward
Id ProductId Qty Location Orderid 1 7 2 2 38 2 8 1 2 38 3 7 1 2 38产品外向
Id ProductId Qty Location Orderid 1 7 12 2 38 2 8 1 2 38我需要 stockoutward 的输出为 ProductId 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
【问题讨论】:
标签: sql-server sql-server-2008