您好我有这个select语句;
select
I.itemno,
avg(D.unit_price) as average
from
INVENTORY I,
ORDER_DTL D
where
I.id = D.INVENTORY_ID
group by I.itemno;
我想以平均销售价格更新INVENTORY表中的另一列。 有没有办法在一个声明中这样做?
由于 詹姆斯
答案 0 :(得分:0)
UPDATE INVENTORY A SET avg_price =
(select
avg(D.unit_price) as average
from
INVENTORY I,
ORDER_DTL D
where
I.id = D.INVENTORY_ID
AND I.itemno = A.itemno
group by I.itemno);
这不会有帮助吗?