What is wrong with my query on Access 2010? -
i have query on access 2010 (accdb) working fine:
select b.category_name, a.item_name, (select count(*) tbl_stock_receiving x x.safe_stock_id = a.id) received, (select count(*) tbl_stock_issuance y y.stock_receiving_id = a.id) issued, (received-issued) on_hand, a.safe_stock tbl_safe_stock inner join tbl_category b on a.category_id = b.id order a.item_name; now, need modify include simple statement
... on a.category_id = b.id a.safe_stock > on_hand order a.item_name; ... when run query, access keeps popping parameter value
on_hand
on_hand alias can see on
(received-issued) on_hand what wrong in query?
you've defined on_hand name of output column, sql parser isn't clever enough go through query , "reverse engineer" on_hand came from. therefore, you'd need use where a.safe_stock > (received - issued), aliases output columns, too.
so try wrapping whole thing subquery , applying where , order by clauses afterward:
select * ( select b.category_name, a.item_name, (select count(*) tbl_stock_receiving x x.safe_stock_id = a.id) received, (select count(*) tbl_stock_issuance y y.stock_receiving_id = a.id) issued, (received-issued) on_hand, a.safe_stock tbl_safe_stock inner join tbl_category b on a.category_id = b.id ) safe_stock > on_hand order item_name edit
the suggestion above resulted in "query complex" error, next suggestion save original query [stockcheckbasequery] , do
select * stockcheckbasequery safe_stock > on_hand order item_name that appears have been successful.
Comments
Post a Comment