以下の select ステートメントを使用して、別のテーブルの製品の数量を更新しますtablex
。このクエリの製品番号をproductnumber tablexに一致させ、このステートメントで見つかった数量をtablexの既存の数量に追加する方法を理解できないようです。
select
p.ProductNumber, sod.Quantity ,so.StateCode
from
SalesOrderDetail sod
right join
ProductAssociation pa on sod.ProductId = pa.ProductId
left join
Product p on pa.AssociatedProduct = p.ProductId
left join
SalesOrder so on so.SalesOrderId = sod.SalesOrderId
where
so.StateCode = '3'