前月を当月にいれるのはSQLとしてはあまり推奨できません
どうしてもということであればこんな感じで
SQL
1create table tbl(ym date,code varchar(20),prev int,current int,unique(ym,code));
2insert into tbl(ym,code,current) values
3('2021-11-01','a1234',10),
4('2021-12-01','a1234',20),
5('2022-02-01','a1234',200),
6('2022-03-01','a1234',300),
7('2022-04-01','a1234',null),
8('2022-02-01','b5678',1000),
9('2022-03-01','b5678',2000);
// 更新
SQL
1update tbl as t1,tbl as t2
2set t1.prev=t2.current
3where t2.ym + interval 1 month=t1.ym and t1.code=t2.code;