Query SELECT count(distinct a.mrepc_no) as total, a.igcat_id, b.category as product_name, c.rubber_name, c.rubber_type FROM company_product_exp_upd a, igroup_cat_upd b, rubber_type c, company_details d, company_product e WHERE a.mrepc_no = d.mrepc_no and d.mrepc_no = e.mrepc_no AND (d.not_active IS NULL OR d.not_active = 0) AND a.igcat_id = '154' AND a.igcat_id = b.cat_id AND b.rubber_type = c.rubber_type group by a.igcat_id order by b.category failed