-- Clear the data that has been digested in sales and re-inserted after verification.
Drop table pcje2007
Select lsh, pcrq, xmbm, pH, sqys, sqyje, bqss, bqsje, bqfs, bqfje, JCs, PCs, sqyje + bqsje-bqfje + (dslsj * (PCs-JCs )) as pcje, round (PCs * dslsj, 2) As pcje2 into pcje2007 from zy_yp1_pcb where datediff (mm, pcrq, '2017-01-01 ') = 0
Delete from pcje2007 where sqys = 0 and bqss = 0 and bqfs = 0 and JCs = 0 and PCs = 0
Select. pcrq, B. pcrq,. xmbm,. pH,. sqyje, B. pcje, B. pcje2 from zy_yp1_pcb A, pcje2007 B where datediff (mm,. pcrq, '2014-2-01 ') = 0 and. xmbm = B. xmbm and. pH = B. pH and ABS (. sqyje-b.pcje2)> 0
Select * into limit 200701 from zy_yp1_pcb
Update zy_yp1_pcb set sqyje = B. pcje2 from zy_yp1_pcb A, pcje2007 B where datediff (mm,. pcrq, '2017-1-01 ') = 0 and. xmbm = B. xmbm and. pH = B. pH and ABS (. sqyje-b.pcje2)> 0
Select * From zy_sys2_ypzdk where GBM = '2013'
Update zy_yp1_pcb set dslsj = round (sqyje + bqsje)/(Case (sqys + bqss) When 0 then 1 else sqys + bqss end), 4) from zy_yp1_pcb Where ABS (sqyje + bqsje)/(Case (sqys + bqss) When 0 then 1 else sqys + bqss end)-dslsj)> 1 and datediff (mm, pcrq, '2014-2-01 ') = 0 and round (sqyje + bqsje)/(Case (sqys + bqss) When 0 then 1 else sqys + bqss end )), 4) <> 0
Select xmbm, dslsj, round (sqyje + bqsje)/(Case (sqys + bqss) When 0 then 1 else sqys + bqss end), 4) from zy_yp1_pcb Where ABS (sqyje + bqsje)/(Case (sqys + bqss) When 0 then 1 else sqys + bqss end)-dslsj)> 1 and datediff (mm, pcrq, '2014-2-01 ') = 0 and round (sqyje + bqsje)/(Case (sqys + bqss) When 0 then 1 else sqys + bqss end )), 4) <> 0