在SET中使用算术表达式进行UPDATE

时间:2017-09-29 14:02:42

标签: oracle sql-update

我希望将更新子查询中所选列的值相乘并获得一个新值,如下所示:

来自TAO的

A.GROSSA.GROSS乘以SPLIT文件中选定的B.PERCENT_VALUE

我试过如下:

UPDATE PS_HR_TAO10 A SET A.GROSS = (A.GROSS_AMT * B.PERCENT_VALUE) 
(SELECT B.PERCENT_VALUE FROM PS_Z_NEW_FY_SPLIT B
WHERE A.EMPLID = B.EMPLID)
WHERE A.PAY_END_DT = '09-JUL-2016';

1 个答案:

答案 0 :(得分:0)

我会选择合并声明:

merge into PS_HR_TAO10 A
using (select EMPLID, PERCENT_VALUE from PS_Z_NEW_FY_SPLIT) B
on (A.EMPLID = B.EMPLID)
when matched then update set
A.GROSS = A.GROSS_AMT * B.PERCENT_VALUE
WHERE A.PAY_END_DT = '09-JUL-2016';