select b.spbh,b.spmch,b.shpgg,b.dw,b.jlgg,b.shengccj,b.shpchd,b.pizhwh,b.jixing,g.shl,g.hshj,g.hsje,a.pckhdj,a.bmgs,a.xsbmxz,a.fukfs,a.gebjj,a.pihao,a.baozhiqi,a.sxrq,a.pici,c.huowname,a.jwh,d.danwbh,d.dwmch,a.ywlxr,j.username,j.ywy,h.kaiprq,h.ontime,f.退货人
from sphwph a,spkfk b,huoweizl c,mchk d,(select distinct 单位编号,退货人 from fr_spkfkbakjxqth161229a) f,jh_rkmx g,jh_rkhz h,jh_djhz j
where g.spid=b.spid and a.spid=b.spid and a.hw=c.hw and a.dwbh=d.dwbh and g.sxrq<=‘2017-09-30‘ and a.sxrq<>‘‘ and d.danwbh=f.单位编号
and g.djbh like ‘jhc%‘ and g.rq>=‘2016-12-29‘ and g.rq<=‘2016-12-30‘ and g.pici=a.pici and g.hw=a.hw and g.djbh=h.djbh and h.kaipiaodjbh=j.djbh
order by d.danwbh
原文:http://bks2015.blog.51cto.com/9847303/1889811