Query SELECT count(a.item_id) as total, b.item as product_name ,b.item_id FROM company_product_exp_upd a, igcat_item_upd b, company_details c, company_product d WHERE a.mrepc_no = c.mrepc_no AND c.mrepc_no = d.mrepc_no AND a.igcat_id = '007' AND a.item_id = '0023' AND a.item_id = '0023' AND (c.not_active IS NULL OR c.not_active = 0) AND a.item_id = b.item_id group by a.item_id order by b.item failed