|
发表于 2010-1-28 11:22:11
|
显示全部楼层
建议楼主把SQL语句解释一下啊
select m.ccuscode as 客户编码,m.ccusname as 客户名称,n.dDate as 单据时间,n.cSOCode as 生产令,f.dPreMoDate as 完工日期,
f.irowno as 行号,s.cinvcode as 成品编码,s.cinvname as 成品,f.iQuantity as 成品数量,
r.BaseQtyN as 分子用量,r.BaseQtyD as 分母用量,r.BaseQtyN/r.BaseQtyD as 单位用量,
c.cinvcode as 存货编码,c.cinvname as 存货名称,c.cInvAddCode as 存货代码,c.cInvStd as 规格型号,b.cFree3 as 颜色,
c.cinvccode as 存货大类,g.cComUnitName as 辅计量,h.cComUnitName as 主计量,g.iChangRate as 换算率,
f.iQuantity*(r.BaseQtyN/r.BaseQtyD) as 计划数量,
round((f.iQuantity*(r.BaseQtyN/r.BaseQtyD))/isnull(g.iChangRate,1),0) as 计划件数,
b.iquantity as 订单数量,b.iquantity/isnull(g.iChangRate,1) as 订单件数,
sum(d.fValidQuantity) as 到货数量,sum(d.fValidQuantity)/isnull(g.iChangRate,1) as 到货件数,
sum(d.fValidinQuan) as 入库数量,sum(d.fValidinQuan)/isnull(g.iChangRate,1) as 入库件数--,k.iquantity
from so_somain n
left join so_sodetails f on n.id=f.id
left join inventory s on f.cinvcode=s.cinvcode and s.cinvccode like '0106%'
left join bas_part p on f.cinvcode=p.invcode
left join bom_parent q on p.partid=q.ParentId
left join bom_opcomponent r on q.bomid=r.BomId
left join bas_part p1 on r.ComponentId=p1.partid
left join inventory c on p1.invcode=c.cinvcode
left join PO_Podetails b on f.iSOsID=b.sodid and b.sotype='1' and c.cinvcode=b.cinvcode
left join PU_ArrivalVouchs d on b.ID=d.iPOsID
left join inventoryclass e on c.cinvccode=e.cinvccode
left join ComputationUnit g on c.cSTComUnitCode=g.cComUnitCode
left join ComputationUnit h on c.cComUnitCode=h.cComUnitCode
left join customer m on n.ccuscode=m.ccuscode
--left join rdrecords k on f.iSOsID=k.isodid and k.isotype='1'
where f.cinvcode='01060303005'
group by m.ccuscode,m.ccusname,n.dDate,n.cSOCode,f.dPreMoDate,
f.irowno,s.cinvcode,s.cinvname,f.iQuantity,
r.BaseQtyN,r.BaseQtyD,
c.cinvcode,c.cinvname,c.cInvAddCode,c.cInvStd,b.cFree3,
c.cinvccode,g.cComUnitName,h.cComUnitName,g.iChangRate,
b.iquantity--,k.iquantity |
|