可以这样更新
update Product SET 库存= T1.数量 - T2.数量
from
(select 商品名称,sum(数量) as 数量 from purchase group by 商品名称) as T1,
(select 商品名称,sum(数量) as 数量 from sale group by 商品名称) as T2
where T1.商品名称 = T2.商品名称 and product.商品名称 = T1.商品名称
UPDATE Product SET 库存=(
(SELECT sum(数量) FROM Purchase WHERE 商品名称='Product.商品名称')
-(SELECT sum(数量) FROM Sale WHERE 商品名称='Product.商品名称')
where 商品名称='Product.商品名称'