标签:代码 count lin zid hang out 重复 join concat
--写法中jg_info中的中包装与小包装为一行,出现重复行--另外一种写法,未清暂存区的可以显示
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‘
标签:代码 count lin zid hang out 重复 join concat
原文地址:https://blog.51cto.com/bks2015/2542702