Can anyone find out what the problem is?
In this condition:
MAX(RESIGNATION_DATE IS NULL)= 0
you compare MAX(NULL)=0howRESIGNATION_DATE IS NULL
Your request should be:
select emp_code, res_date
From Table_name
where res_date IS NULL group by emp_code
UNION
select emp_code, MAX(res_date )
From Table_name
where emp_code NOT IN
(select emp_code From Table_name
where res_date IS NULL)
group by emp_code
EDIT
select DISTINCT emp_code, res_date
From Table_name
where res_date IS NULL
UNION
select emp_code, MAX(res_date )
From Table_name
where emp_code NOT IN
(select emp_code From Table_name
where res_date IS NULL)
group by emp_code
source
share