SELECT DISTINCT C.ROLEUSER ,A.HCSC_RECIPIENT_ID , A.HCSC_RECIPIENT_NM FROM PS_HCSC_RECIPIENT A , PS_HCSC_RCPNT_ROLE B , PSROLEUSER C WHERE (A.HCSC_RECIPIENT_ID = B.HCSC_RECIPIENT_ID AND A.STATUS = 'A' AND B.ROLENAME = C.ROLENAME) UNION SELECT DISTINCT C2.ROLEUSER ,A2.HCSC_RECIPIENT_ID , A2.HCSC_RECIPIENT_NM FROM PS_HCSC_RECIPIENT A2 , PS_HCSC_RCPNT_ROLE B2 , PSROLEUSER C2 WHERE (A2.HCSC_RECIPIENT_ID = B2.HCSC_RECIPIENT_ID AND A2.STATUS = 'A' AND B2.ROLENAME = ' ') UNION SELECT DISTINCT C1.ROLEUSER ,A1.HCSC_RECIPIENT_ID , A1.HCSC_RECIPIENT_NM FROM PS_HCSC_RECIPIENT A1 , PSROLEUSER C1 WHERE A1.STATUS = 'A' AND NOT EXISTS( SELECT 'X' FROM PS_HCSC_RCPNT_ROLE B1 WHERE A1.HCSC_RECIPIENT_ID = B1.HCSC_RECIPIENT_ID)
|