描述的是有点不清楚 你先看看这样是你要的吗?update b set cnt=cnt/(select count(*) from a where a.id=b.id), p=p/(select count(*) from a where a.id=b.id), q=q/(select count(*) from a where a.id=b.id); commit;
update b set (b.p,b.q)=(select a.c,a.d from a where a.id=b.id and a.cnt=b.cnt)
merge into B using A on (A.ID = B.ID) when matched then update set b.cnt = a.cnt,b.p = a.p b.q = a.q when not matched then insert(id,cnt,p,q) values(a.id,a.cnt,a.p,a.q)
p=p/(select count(*) from a where a.id=b.id),
q=q/(select count(*) from a where a.id=b.id);
commit;
using A
on (A.ID = B.ID)
when matched then
update set b.cnt = a.cnt,b.p = a.p b.q = a.q
when not matched then
insert(id,cnt,p,q)
values(a.id,a.cnt,a.p,a.q)