Query2a SELECT count(DISTINCT a.mrepc_no) as totaluser, c.state_id, c.state, c.flag, d.item FROM company_product_exp_upd a, company_details b, state c, igcat_item_upd d, company_product e WHERE a.mrepc_no = b.mrepc_no and b.mrepc_no = e.mrepc_no AND (b.not_active IS NULL OR b.not_active = 0) AND d.rubber_type = 'HSH' AND a.item_id = d.item_id AND a.igcat_id = '025' AND b.state_id = c.state_id group by c.state order by d.item failed