我可以知道如何更新 Sql Calculation 语句吗?
例如,我想将总和更新到表格
下面是代码
SELECT p.Qty AS pQty,
SUM(t.Qty) AS tQty,
p.Qty - SUM(t.Qty) AS total ,
p.PName
FROM tblTempTransaction t ,
tblProducts p
WHERE t.UserID= 2
AND t.OrderID=1
AND p.pid = t.pid
GROUP BY t.UserID,
p.qty ,
p.PName ,
t.OrderID
UPDATE tblProducts
SET qty = p.Qty - SUM(t.Qty)
WHERE t.UserID= 2
AND t.OrderID=1
AND p.pid = t.pid
GROUP BY t.UserID,
p.qty ,
p.PName ,
t.OrderID
我将从 set qty = p.Qty - SUM(t.Qty) 中得到错误
我可以知道如何解决这个问题吗?谢谢。