求救!很棘手的问题!
select a.pm,a.gg,b.trsl as trsl,'0','0',c.gxhgl,round(b.trsl*c.gxhgl,0) ,
a.sjsl,c.hgldj,(a.sjsl- round(b.trsl*c.gxhgl,0))*c.hgldj From
(select pm,gg,gx,sum(hg) as sjsl from ysd where gx = '压' and zg = '锻压李班' and rq >= '2003-10-26' and rq <= '2003-11-25'group by pm,gg,gx)
as a inner Join
(select cpmc,cpgg,sum(sl) as trsl from xld where dybz = '锻压李班' and rq >= '2003-10-26' and rq<= '2003-11-25'group by cpmc,cpgg) as b
on a.pm = b.cpmc and a.gg = b.cpgg
Inner Join cpgx As c
on a.pm = c.pm and a.gg = c.gg where c.gx = '压'
pm,cpmc: 产品名称,gg,cpgg:产品规格,trsl: 投入数量,gxhgl: 工序合格率
sjsl: 实际数量,hgldj: 合格率单价 gx: 工序,zg:职工,dybz:锻压班组
ysd : 验收单 xld: 下料单
现在是两个表中都有的数据才可以查出来,要想把一个表中有而另一个表中没有的记录也查出来,如何实现?
如果有下料数,没有产出数,则实际数量为0
有产出数,没有下料数,则投入数量为0