from eis_users eu where eu.roles_id in (3, 4, 5) and (eu.active_status ='N'or (notexists (select'X'from eis_entry_exit_ge eeee where eeee.user_id= eu.id and eeee.exit_ge_date isnull))); -- EXISTS (SELECT 'X' FROM TABLE.)
Code ---------------not correct ----------null will return if single project_won used only----- Selectcount(1),ep.project_won -- here "count" ,only affect the result from eis_projects ep groupby ep.project_won havingcount(1) >1;-- count in having ==> affect each group --it is ok selectcount(1) from (select1 from eis_projects ep groupby ep.project_won havingcount(1) >1);