我有以下结构的两个表:
表格1:
ITEM | JAN | FEB | MAR | APR | MAY | JUN
___________________________________________
Item A| 50 | 10 | 25 | NULL| NULL| NULL
Item C| 26 | 20 | 23 | NULL| NULL| NULL
Item B| 25 | 30 | 22 | NULL| NULL| NULL
表 2:
ITEM | JAN | FEB | MAR | APR | MAY | JUN
___________________________________________
Item A| NULL| NULL| NULL| 32 | 26 | 12
Item B| NULL| NULL| NULL| 25 | 24 | 10
Item D| NULL| NULL| NULL| 22 | 35 | 14
我正在尝试合并表,以获得以下结果:
ITEM | JAN | FEB | MAR | APR | MAY | JUN
___________________________________________
Item A| 50 | 10 | 25 | 32 | 26 | 12
Item B| 25 | 30 | 22 | 25 | 24 | 10
Item C| 26 | 20 | 23 | NULL| NULL| NULL
Item D| NULL| NULL| NULL| 22 | 35 | 14
我尝试了以下查询:
MERGE INTO TABLE1 a USING (
SELECT REBATE_ITEM, JAN, FEB, MAR, APR, MAY FROM TABLE2
) b
ON (TRIM(a.ITEM) = TRIM(b.ITEM) AND a.JUN is null)
WHEN MATCHED THEN
UPDATE SET
a.APR = b.APR,
a.MAY = b.MAY,
a.JUN = b.JUN
我得到以下结果: SQL 错误:ORA-38104:无法更新 ON 子句中引用的列:
关于如何完成此合并/加入/无论如何的任何想法?