select * from (
SELECT CRK.物料编号,sum(CRK.数量) as 当前库存 from "备品备件出入库详情表" as CRK GROUP BY 物料编号) as a1
LEFT JOIN
(SELECT CRK1.物料编号,sum(CRK1."采购单价" * crk1."数量")/sum(CRK1."数量") as 采购均价
FROM "备品备件出入库详情表" AS CRK1 where CRK1."数量">0
GROUP BY CRK1.物料编号) as a2
on a1.物料编号=a2.物料编号;
不知道这个是否符合您的需求 |