select DISTINCT pm.plan_id,mp.DISENROLLMENT_REASON_CODE ,a.member_member_id,mp.plan_start_date,mp.plan_end_date,a.APPLICATION_STATUS,a.application_type,CASE WHEN a.application_Status='CMSAPPR' AND a.APPLICATION_TYPE= 'CANDISENR' THEN 'Disenrollment Cancelled' ELSE '' END AS DISENROLLMENTSTATUS from applications a,member_plans mp,product_master pmWHERE a.member_member_id =mp.member_member_idAND a.customer_id=pm.customer_idAND $X{IN,PLAN_ID,PlanID}UNION select DISTINCT pm.plan_id,mp.DISENROLLMENT_REASON_CODE ,a.member_member_id,mp.plan_start_date,mp.plan_end_date,a.APPLICATION_STATUS,a.application_type,CASE WHEN a.application_Status<>'CMSAPPR' AND a.APPLICATION_TYPE= 'CANDISENR' THEN 'Disenrollment Cancellation In Progress' ELSE '' END AS DISENROLLMENTSTATUS from applications a,member_plans mp,product_master pm WHERE a.member_member_id =mp.member_member_idAND a.customer_id=pm.customer_id