- ".TB_PREF."stock_moves.loc_code,
- SUM(".TB_PREF."stock_moves.qty) AS qty_on_hand
- FROM ".TB_PREF."stock_master,
- ".TB_PREF."stock_category,
- ".TB_PREF."stock_moves
- WHERE ".TB_PREF."stock_master.stock_id=".TB_PREF."stock_moves.stock_id
- AND ".TB_PREF."stock_master.category_id=".TB_PREF."stock_category.category_id
+ IF(".TB_PREF."stock_moves.stock_id IS NULL, '', ".TB_PREF."stock_moves.loc_code) AS loc_code,
+ SUM(IF(".TB_PREF."stock_moves.stock_id IS NULL,0,".TB_PREF."stock_moves.qty)) AS qty_on_hand
+ FROM (".TB_PREF."stock_master,
+ ".TB_PREF."stock_category)
+ LEFT JOIN ".TB_PREF."stock_moves ON
+ (".TB_PREF."stock_master.stock_id=".TB_PREF."stock_moves.stock_id OR ".TB_PREF."stock_master.stock_id IS NULL)
+ WHERE ".TB_PREF."stock_master.category_id=".TB_PREF."stock_category.category_id