0
我寫了這個查詢以獲得新的價值更新語句援助
select
ol.ordernumber,
sum(ol.Quantity * ol.each * ol.OriginalPrice) + s.ShippingCost as New Cost
from
orderlines ol, orders o, ShippingMethods s
where
ol.ordernumber = o.OrderNumber
and o.ShippingMethod = s.ShippingMethod
and CreateDate between '2015-05-01' and '2015-05-31'
group by
ol.OrderNumber, s.ShippingCost
我想用一個語句來更新像
update Orders
set TotalRedoCostIncludingShipping = NewCost
,我只是不知道如何將兩個查詢鏈接在一起,以通過訂單號更新訂單表。
請標記與您正在使用的數據庫你的問題。並學習使用明確的'JOIN'語法。簡單的規則:永遠不要在'FROM'子句中使用逗號。 –
Microsoft SQL 2008r2 – JeffreyLazo
我鼓勵您在每次需要時都會導出數據,而不是存儲它。 – Bohemian