更新表(多表相关联)
update f_shortforest forest
set forest.forestquantity = (select (decode(sum(detail.quantity),
null,
0,
sum(detail.quantity)) * 0.6 +
decode(forest.forestquantity,
null,
0,
forest.forestquantity) * 0.4)
FROM d_salerplan@tpo master,
d_salerplandetail@tpo detail
where master.sorderid = detail.sorderid
and forest.estimateyear =
substr(master.ordermonth, 1, 4)
and forest.month =
substr(master.ordermonth, 5, 2)
and forest.productid = detail.productid
group by detail.productid)
where exists(select detail.quantity
FROM d_salerplan@tpo master,
d_salerplandetail@tpo detail
where master.sorderid = detail.sorderid
and forest.estimateyear =
substr(master.ordermonth, 1, 4)
and forest.month =
substr(master.ordermonth, 5, 2)
and forest.productid = detail.productid);
浙公网安备 33010602011771号