码迷,mamicode.com
首页 > 其他好文 > 详细

未扫jgm代码

时间:2020-10-21 20:58:30      阅读:24      评论:0      收藏:0      [点我收藏+]

标签:代码   count   lin   zid   hang   out   重复   join   concat   

--写法中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代码

标签:代码   count   lin   zid   hang   out   重复   join   concat   

原文地址:https://blog.51cto.com/bks2015/2542702

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!