SELECT shangpinleibie.商品类别, (SELECT SUM(shangpin.库存) FROM shangpin WHERE LEFT(shangpin.类, lng位数*2)=shangpinleibie.类) AS 库存总量
FROM shangpinleibie
WHERE (((shangpinleibie.页)=FORMS!商品类别!页)) Or (((shangpinleibie.商品类别) Is Null))
ORDER BY shangpinleibie.行号;