select *,h1.购入库-h2.产退料+h3.修退料 as 合计 from (select 物料编号,物料名称,型号规格,计量单位,供应商,sum(入库数量) as 购入库 from [123$] where 入库类型="采购入库" group by 物料编号,物料名称,型号规格,计量单位,供应商) as h1,(select 物料编号,物料名称,型号规格,计量单位,供应商,sum(入库数量) as 产退料 from [123$] where 入库类型="生产退料" group by 物料编号,物料名称,型号规格,计量单位,供应商) as h2,(select 物料编号,物料名称,型号规格,计量单位,供应商,sum(入库数量) as 修退料 from [123$] where 入库类型="维修退料" group by 物料编号,物料名称,型号规格,计量单位,供应商) as h3 where h1.物料编号=h2.物料编号 and h1.物料编号=h3.物料编号
这个语句。还是有点问题,希望高手能帮我找找原因,这样这个题目就解决了。我就差最后一步了。
[ 本帖最后由 monvzhilei 于 2009-3-25 14:51 编辑 ] |