select a.货号,a.编号,b.规格,c.库存(入数量-出数量)
from 表1 as a,表2 as b
(select 编号,sum(入数量 -出数量) as 库存
from 表3 group by 编号) as c
where a. 编号=b. 编号 and a.编号=c. 编号
SELECT 表1.货号,表1.编号,表2.规格,sum(表3.入数量-表3.出数量) as 库存
FROM 表1 LEFT JOIN 表2 ON 表1.编号=表2.编号
LEFT JOIN 表3 ON 表1.编号=表3.编号
group by 表1.货号,表1.编号,表2.规格
select t.* ,(select sum(c.入数量) from 表3 as c where c.编号 = t.编号) as 入数量 ,(select sum(c.出数量) from 表3 as c where c.编号 = t.编号) as 入数量 from (select a.货号,b.编号,b.规格 from 表1 as a inner join 表2 as b on a.编号 = b.编号)