解决方案: |
看产品的入库数量和材料消耗情况,是指按照单据还是按照存货汇总所有的数据,如果按照单据,根据产品结构作配比出库只是做出库单,所以出库单与产成品入库单并没有对应关系,所以无法察看,如果按照存货汇总所有数据,您可以根据产品结构子表与rdrecord(s)中的产成入库单关联,并与rdrecord(s)中的材料出库单关联,取得数据,下面有一个简单的查询以供参考,只是取得产品结构的中间级,没有取到末级。 select a.cpspcode,b.rk,b.rje,a.cpscode,c.ck ,c.cje from productstructures a left join (select cinvcode,sum(iquantity) as rk ,sum(iprice) as rje from rdrecord a inner join rdrecords b on a.id=b.id where cvouchtype='11' group by cinvcode) b on a.cpspcode=b.cinvcode left join (select cinvcode,sum(iquantity) as ck ,sum(iprice) as cje from rdrecord a inner join rdrecords b on a.id=b.id where cvouchtype='10' and cbustype='配比出库' group by cinvcode) as c on a.cpscode=c.cinvcode |