三菱先进先出和定位怎么配合使用

三菱先进先出和定位怎么配合使用,第1张

1、首先三菱先进先出和定位使用WSFL指令,将数据保存至D0。

2、其次启动GXDeveloper,点击菜单的工程,创建新工程。

3、最后将数据移至D100-D120的数据库中,即可先进先出和定位配合使用了。

create table 表1(货号 varchar(20),批次 int ,数量 int)

create table 表2(货号 varchar(20) ,数量 int)

/*------------------------------*/

insert into 表1

select '001', 1, 100 union all

select '001', 2, 200 union all

select '001', 3, 300

/*------------------------------*/

insert into 表2

select '001', 400

/*------------------------------*/

select * from 表1

select * from 表2

/*------------------------------*/

select t1.货号,t1.批次,

case when ((select isnull(sum(数量),0) from 表1 t3 where t3.货号=t1.货号 and t3.批次<t1.批次)-isnull(t2.new_数量,0))<0

then case when ((select sum(数量) from 表1 t4 where t4.货号=t1.货号 and t4.批次<=t1.批次)-isnull(t2.new_数量,0))<0 then 0

else ((select sum(数量) from 表1 t4 where t4.货号=t1.货号 and t4.批次<=t1.批次)-isnull(t2.new_数量,0))

end

else t1.数量

end as 批次剩余库存数

from 表1 t1

left join (select 货号,sum(数量) as new_数量 from 表2 group by 货号) t2

on t1.货号=t2.货号

/*------------------------------*/

PS:上面将null转换为0的函数为isnull,是SQL SERVER下的函数,你只要根据你的数据转换为对应函数就可以了,如oracle是nvl,mysql是ifnull等等.

有问题hi我


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/10063562.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-04
下一篇2023-05-04

发表评论

登录后才能评论

评论列表(0条)

    保存