--查自身结转数量是否不正确 select shqjzhshl,cwjcsl+cksl-bqrsh,bqrsh-cksl, from ymjzhk where spid=‘SPH00000562‘ order by jzhh desc --检查结转库与流水库结转数据是否一致 select jzhh,sum(rkshl),sum(chkshl),sum(rkshl)-sum(chkshl) From splsk where spid=‘SPH00000562‘ group by jzhh order by jzhh desc --对比发现JZH00000040结转库cksl多出了90 --备份要更新数据 select into fr_ymjzhk20190102_SPH00000562 from ymjzhk where spid=‘SPH00000562‘ and nian=‘2018‘ order by jzhh desc --更新数据 update ymjzhk set cksl=1616-90,bqxsshl=1616-90,bqysh=bqysh+90,cwjcsl=cwjcsl+90 where spid=‘SPH00000562‘ and jzhh=‘JZH00000040‘ update ymjzhk set shqjzhshl=shqjzhshl+90,bqysh=bqysh+90,cwjcsl=cwjcsl+90 where spid=‘SPH00000562‘ and jzhh=‘JZH00000041‘ update ymjzhk set shqjzhshl=shqjzhshl+90,bqysh=bqysh+90,cwjcsl=cwjcsl+90 where spid=‘SPH00000562‘ and jzhh=‘JZH00000042‘ update ymjzhk set shqjzhshl=shqjzhshl+90,bqysh=bqysh+90,cwjcsl=cwjcsl+90 where spid=‘SPH00000562‘ and jzhh=‘JZH00000043‘ update ymjzhk set shqjzhshl=shqjzhshl+90,bqysh=bqysh+90,cwjcsl=cwjcsl+90 where spid=‘SPH00000562‘ and jzhh=‘JZH00000044‘ update ymjzhk set shqjzhshl=shqjzhshl+90,bqysh=bqysh+90,cwjcsl=cwjcsl+90 where spid=‘SPH00000562‘ and jzhh=‘JZH00000045‘ update ymjzhk set shqjzhshl=shqjzhshl+90,bqysh=bqysh+90,cwjcsl=cwjcsl+90 where spid=‘SPH00000562‘ and jzhh=‘JZH00000046‘ update ymjzhk set shqjzhshl=shqjzhshl+90,bqysh=bqysh+90,cwjcsl=cwjcsl+90 where spid=‘SPH00000562‘ and jzhh=‘JZH00000047‘ --更新结转数量(容易遗忘) update spkfjc set shqjzhshl=230+90 where spid=‘SPH00000562‘ update hwsp set jzshl=230+90 where spid=‘SPH00000562‘ and hw=‘HWI00000025‘ --检查所有结转数量是否正确 select * from spkfjc where cwsqjzsl<>kcshl