U8 存货期初余额 货位

1、InvpositionSum:存货货位存量表

2、invPosition:存货货位记录表

3、期初:select a.cwhcode,b.cinvcode,b.iquantity,isnull(b.cfree1,'测试') cfree1,isnull(b.cfree2,'测试') cfree2,isnull(b.cfree3,'测试') cfree3,b.cposition from rdrecord34 a left join rdrecords34 b on a.id=b.id

1是2的group合计

2和3一一对应

期初出错删除顺序:

delete from Rdrecords34 where id in (select id from Rdrecord34 where cwhcode ='214')

delete from Rdrecord34 where cwhcode ='214'

delete from invPosition where cwhcode ='214'

delete from InvpositionSum where cwhcode ='214'

修改自由项

update InvpositionSum set cfree1=UFDATA_006_2018..qichukucun.cfree1 from UFDATA_006_2018..qichukucun

where InvpositionSum.autoid=UFDATA_006_2018..qichukucun.autoid

select * from (select a.cwhcode,b.cinvcode,b.iquantity,isnull(b.cfree1,'测试') cfree1,isnull(b.cfree2,'测试') cfree2,isnull(b.cfree3,'测试') cfree3,b.cposition from rdrecord34 a left join rdrecords34 b on a.id=b.id ) c left join

(select cwhcode,cinvcode,iquantity,(case cfree1 when '' then '测试' else cfree1 end) cfree1,(case cfree2 when '' then '测试' else cfree2 end) cfree2,(case cfree3 when '' then '测试' else cfree3 end) cfree3,cposcode from InvpositionSum ) d on

c.cwhcode=d.cwhcode and c.cinvcode=d.cinvcode and c.cposition=d.cposcode and c.cfree1=d.cfree1 and c.cfree2=d.cfree2 and c.cfree3=d.cfree3

原文地址:https://www.cnblogs.com/passerlee/p/9999994.html