我在 Access 2010 (accdb) 上有这个查询,它工作得很好:
SELECT b.category_name, a.item_name,
(SELECT COUNT(*) FROM tbl_stock_receiving AS x WHERE x.safe_stock_id = a.ID) AS received,
(SELECT COUNT(*) FROM tbl_stock_issuance AS y WHERE y.stock_receiving_id = a.ID) AS issued,
(received-issued) AS on_hand, a.safe_stock
FROM tbl_safe_stock AS a INNER JOIN tbl_category AS b
ON a.category_id = b.id
ORDER BY a.item_name;
现在,我需要修改它以包含一个简单的 WHERE 语句
...
ON a.category_id = b.id
WHERE a.safe_stock > on_hand
ORDER BY a.item_name;
...
当我运行查询时,Access 不断弹出一个参数值
手上
on_hand 是一个别名,如您所见
(received-issued) AS on_hand
我的查询可能有什么问题?