SELECT A.EMPLID , A.EMPL_RCD , CASE WHEN B.PTAI_LIST_STATUS='IP' THEN ( SELECT MIN(ITM.PTAI_DUE_DATE) FROM PS_PTAI_ITEM ITM WHERE ITM.PTAI_LIST_ID =B.PTAI_LIST_ID and ITM.PTAI_DUE_DATE IS NOT NULL AND ITM.PTAI_STATUS <> 4) ELSE %DateNull END , (CASE WHEN B.PTAI_LIST_STATUS='IP' THEN ( SELECT COUNT(*) FROM PS_PTAI_ITEM ITM WHERE ITM.PTAI_LIST_ID=B.PTAI_LIST_ID AND ITM.PTAI_DUE_DATE IS NOT NULL AND ITM.PTAI_STATUS <> 4) ELSE 0 END ) FROM PS_HR_OBD_TRIGGER A , PS_PTAI_LIST B , PS_PTAI_CONTEXT C , PS_PTAI_CONTEXT D WHERE B.PTAI_PARENT_TMPL = A.AGC_LIST_ID AND C.PTAI_LIST_ID = B.PTAI_LIST_ID AND C.RECNAME = 'HR_OBD_CONTEXT' AND C.FIELDNAME = 'EMPLID' AND C.PTAI_KEY_VALUE = A.EMPLID AND D.PTAI_LIST_ID = B.PTAI_LIST_ID AND D.RECNAME = 'HR_OBD_CONTEXT' AND D.FIELDNAME = 'EMPL_RCD' AND D.PTAI_KEY_VALUE = %NumToChar(A.EMPL_RCD)
|