我试图通过在同一个表上执行左外连接来更新表中的 5 列与去年的值。然后我更新其中的“文本”列。我正在使用下面的代码,但它的数量增加了一倍。尽管复制行之间没有数据差异,但事务行数:
insert into table2
select coalesce(a.F_YEAR,b.F_YEAR+1) F_YEAR,
coalesce(a.POSTING_DATE,b.POSTING_DATE+366)POSTING_DATE,
coalesce(a.Material,b.Material),
coalesce(a.R_no,b.R_no),
coalesce(a.Text,b.Text),
a.Amt,
a.X_BUDGET,
a.Y_BUDGET,
a.X_FORECAST,
a.Y_FORECAST
from table2 a
Left outer join table2 b
on a.F_YEAR-1 = b.F_YEAR
and extract(month from a.POSTING_DATE) = extract(month from b.POSTING_DATE)
and a.R_no = b.R_no
and a.MATERIAL = b.MATERIAL
and a.TEXT=b.TEXT;
select *
from table2
where F_Year <= extract(year from current_date('Asia/India'));
update table2 tgt
set tgt.TEXT=b.TEXT
from table3 b
where
tgt.R_no=b.G_L_no,'0' and tgt.TEXT is null;
如何在没有双号的情况下获得正确的输出。行数?
可能重复发生在第一步
insert into table2
。新数据正在插入到原始表中。尝试插入到一些新表中insert into table_new