其他分享
首页 > 其他分享> > 未扫jgm代码

未扫jgm代码

作者:互联网

--写法中jg_info中的中包装与小包装为一行,出现重复行
select djbh, spbh,spmch,kuansbh,is_jg,sl,js,lss,decode( bzlb,0,'整件',1,'中包装',2,'小包装',bzlb) 包装类别,case when bzlb=0 then JS-count(jiang_cd) when bzlb=1 then SL/kuansbh-count(jiang_cd) when bzlb=2 then SL-count(jiang_cd) end 剩余数量, count(jiang_cd) cnt, wm_concat( jiang_cd) mx from (
select t.djbh,
f_get_spbh(spid, yzid) spbh,
(select sp.spmch
from spkfk sp
where sp.spid = t.spid
and sp.yzid = t.yzid) spmch,
(select sp.kuansbh
from spkfk sp
where sp.spid = t.spid
and sp.yzid = t.yzid) kuansbh,
(select sp.is_jg
from spkfk sp
where sp.spid = t.spid
and sp.yzid = t.yzid) is_jg,
sl,js,lss,bzlb,
jg.jiang_cd
from out_sale_billing_d t left join jg_info jg
on t.djbh =jg.ruckd_no
and t.yzid =jg.yez_id
and t.spid =jg.shangp_id
and t.ph=jg.phid) a
where djbh = 'XSGYMA00480669'
and is_jg <>'否'
group by djbh, spbh,spmch,is_jg,sl,js,lss ,bzlb,kuansbh

--另外一种写法,未清暂存区的可以显示

select b.rq,a. from (
select t.djbh,
a.spbh,
a.spmch,a.shpgg,a.shengccj,JS-nvl(zjjgsl,0) 剩余整件码,LSS-nvl(lhjgsl,0) 剩余散件码,a.kuansbh,a.JLGG
sl,js,lss,
nvl(zjjgsl,0) 已扫整件码,nvl(lhjgsl,0) 已散件数量
from spkfk a,out_sale_billing_d t left join
( select yez_id,ruckd_no,shangp_id,phid,0 zjjgsl,sum(lhjgsl) lhjgsl from
(select yez_id,ruckd_no,shangp_id,phid,0 zjjgsl,case when bzlb=1 then count(b.jiang_cd)
kuansbh when bzlb=2 then count(b.jiang_cd) end lhjgsl from jg_info b,spkfk c
where b.yez_id=c.yzid
and b.shangp_id=c.spid
and b.bzlb in ('1','2')
group by yez_id,ruckd_no,shangp_id,phid,kuansbh,bzlb)
group by yez_id,ruckd_no,shangp_id,phid
union all
select yez_id,ruckd_no,shangp_id,phid,count(jiang_cd) zjjgsl,0 lhjgsl from jg_info where bzlb=0
group by yez_id,ruckd_no,shangp_id,phid)jg
on t.djbh =jg.ruckd_no
and t.yzid =jg.yez_id
and t.spid =jg.shangp_id
and t.ph=jg.phid
where a.spid=t.spid and a.yzid=t.yzid and a.is_jg<>'否'
) a,out_sale_billing_m b
where a.djbh=b.djbh and (剩余整件码>0 or 剩余散件码>0)
and to_char(b.rq,'yyyy-mm-dd')>='2020-10-01'

标签:jgm,代码,bzlb,yez,yzid,未扫,jg,djbh,id
来源: https://blog.51cto.com/bks2015/2542702