SELECT DOC.EP_APPRAISAL_ID ,DOC.EMPLID ,DOC.EMPL_RCD ,DOC.PERIOD_BEGIN_DT ,DOC.PERIOD_END_DT ,DOC.EP_MANAGER_ID ,DOC.EP_REVIEW_TYPE ,DOC.EP_TEMPLATE_ID ,ITM.EP_SECTION_TYPE ,ITM.EP_ITEM_ID ,ITM.EP_ITEM_SEQ ,ITM.EP_TITLE ,ITM.EP_ITEM_PCT ,(CASE WHEN SEC.JPM_C_LIST_ID <> ' ' AND ITM.EP_ITEM_STATUS <> ' ' THEN ( SELECT DESCR100 FROM PS_JPM_C_LIST_VW L WHERE L.JPM_C_LIST_ID=SEC.JPM_C_LIST_ID AND L.JPM_C_LIST_VALUE=ITM.EP_ITEM_STATUS) WHEN ITM.EP_ITEM_STATUS <> ' ' THEN ( SELECT XLATLONGNAME FROM PSXLATITEM X WHERE X.FIELDNAME='EP_ITEM_STATUS' AND X.FIELDVALUE = ITM.EP_ITEM_STATUS AND %EffdtCheck(PSXLATITEM X1,X,%CurrentDateIn)) ELSE ' ' END) ,(CASE WHEN SEC.EP_ALL_ITEMS_SW='Y' THEN SEC.RATING_MODEL ELSE ITM.RATING_MODEL END) ,ITM.EP_MGR_REVW_POINTS ,ITM.EP_MGR_REVW_RATING ,ITM.EP_MGR_NUM_RATING ,ITM.EP_TARGET_RATING ,(CASE WHEN %Coalesce(DOC.LASTUPDDTTM,%DateTimeIn('1900-01-01-00.00.00.000000')) >= %Coalesce(DOC.EP_CREATE_DTTM,%DateTimeIn('1900-01-01-00.00.00.000000')) THEN %Coalesce(DOC.LASTUPDDTTM,%DateTimeIn('1900-01-01-00.00.00.000000')) WHEN %Coalesce(DOC.EP_CREATE_DTTM,%DateTimeIn('1900-01-01-00.00.00.000000')) >= %Coalesce(DOC.LASTUPDDTTM,%DateTimeIn('1900-01-01-00.00.00.000000')) THEN %Coalesce(DOC.EP_CREATE_DTTM,%DateTimeIn('1900-01-01-00.00.00.000000')) ELSE %DateTimeIn('1900-01-01-00.00.00.000000') END) FROM PS_EP_APPR DOC , PS_EP_APPR_CHECKPT CHK , PS_EP_APPR_B_SEC SEC , PS_EP_APPR_B_ITEM ITM WHERE DOC.EP_REVIEW_STATUS IN ('TP','EC') AND CHK.EP_APPRAISAL_ID = DOC.EP_APPRAISAL_ID AND ((CHK.EP_CHKPT_COMPLETE = 'C' AND CHK.EP_CHKPT_TYPE = 'S') OR CHK.EP_CHKPT_TYPE = 'C') AND CHK.EP_CHKPT_NBR = ( SELECT MAX(EP_CHKPT_NBR) FROM PS_EP_APPR_CHECKPT CHK1 WHERE CHK1.EP_APPRAISAL_ID = CHK.EP_APPRAISAL_ID AND ((CHK1.EP_CHKPT_COMPLETE = 'C' AND CHK1.EP_CHKPT_TYPE = 'S') OR CHK1.EP_CHKPT_TYPE = 'C')) AND SEC.EP_APPRAISAL_ID = DOC.EP_APPRAISAL_ID AND ITM.EP_APPRAISAL_ID = SEC.EP_APPRAISAL_ID AND ITM.EP_SECTION_TYPE = SEC.EP_SECTION_TYPE UNION SELECT DOC.EP_APPRAISAL_ID ,DOC.EMPLID ,DOC.EMPL_RCD ,DOC.PERIOD_BEGIN_DT ,DOC.PERIOD_END_DT ,DOC.EP_MANAGER_ID ,DOC.EP_REVIEW_TYPE ,DOC.EP_TEMPLATE_ID ,ITM.EP_SECTION_TYPE ,ITM.EP_ITEM_ID ,ITM.EP_ITEM_SEQ ,ITM.EP_TITLE ,ITM.EP_ITEM_PCT ,(CASE WHEN SEC.JPM_C_LIST_ID <> ' ' AND ITM.EP_ITEM_STATUS <> ' ' THEN ( SELECT DESCR100 FROM PS_JPM_C_LIST_VW L WHERE L.JPM_C_LIST_ID=SEC.JPM_C_LIST_ID AND L.JPM_C_LIST_VALUE=ITM.EP_ITEM_STATUS) WHEN ITM.EP_ITEM_STATUS <> ' ' THEN ( SELECT XLATLONGNAME FROM PSXLATITEM X WHERE X.FIELDNAME='EP_ITEM_STATUS' AND X.FIELDVALUE = ITM.EP_ITEM_STATUS AND %EffdtCheck(PSXLATITEM X1,X,%CurrentDateIn)) ELSE ' ' END) ,(CASE WHEN SEC.EP_ALL_ITEMS_SW='Y' THEN SEC.RATING_MODEL ELSE ITM.RATING_MODEL END) ,ITM.REVIEW_POINTS ,ITM.REVIEW_RATING ,ITM.EP_RATING ,ITM.EP_TARGET_RATING ,(CASE WHEN %Coalesce(DOC.LASTUPDDTTM,%DateTimeIn('1900-01-01-00.00.00.000000')) >= %Coalesce(DOC.EP_CREATE_DTTM,%DateTimeIn('1900-01-01-00.00.00.000000')) AND %Coalesce(DOC.LASTUPDDTTM,%DateTimeIn('1900-01-01-00.00.00.000000')) >= %Coalesce(ROLE.LASTUPDDTTM,%DateTimeIn('1900-01-01-00.00.00.000000')) THEN %Coalesce(DOC.LASTUPDDTTM,%DateTimeIn('1900-01-01-00.00.00.000000')) WHEN %Coalesce(DOC.EP_CREATE_DTTM,%DateTimeIn('1900-01-01-00.00.00.000000')) >= %Coalesce(DOC.LASTUPDDTTM,%DateTimeIn('1900-01-01-00.00.00.000000')) AND %Coalesce(DOC.EP_CREATE_DTTM,%DateTimeIn('1900-01-01-00.00.00.000000')) >= %Coalesce(ROLE.LASTUPDDTTM,%DateTimeIn('1900-01-01-00.00.00.000000'))THEN %Coalesce(DOC.EP_CREATE_DTTM,%DateTimeIn('1900-01-01-00.00.00.000000')) WHEN %Coalesce(ROLE.LASTUPDDTTM,%DateTimeIn('1900-01-01-00.00.00.000000')) >=%Coalesce(DOC.LASTUPDDTTM,%DateTimeIn('1900-01-01-00.00.00.000000')) AND %Coalesce(ROLE.LASTUPDDTTM,%DateTimeIn('1900-01-01-00.00.00.000000')) >= %Coalesce(DOC.EP_CREATE_DTTM,%DateTimeIn('1900-01-01-00.00.00.000000'))THEN %Coalesce(ROLE.LASTUPDDTTM,%DateTimeIn('1900-01-01-00.00.00.000000')) ELSE %DateTimeIn('1900-01-01-00.00.00.000000') END) FROM PS_EP_APPR DOC , PS_EP_APPR_ROLE ROLE, PS_EP_APPR_SECTION SEC , PS_EP_APPR_ITEM ITM WHERE DOC.EP_REVIEW_STATUS IN ('AR','AK','PA','RH','IP') AND ROLE.EP_APPRAISAL_ID = DOC.EP_APPRAISAL_ID AND ROLE.EP_ROLE = 'M' AND SEC.EP_APPRAISAL_ID = ROLE.EP_APPRAISAL_ID AND SEC.EP_ROLE = ROLE.EP_ROLE AND SEC.EP_REVIEWER_ID = ROLE.EP_REVIEWER_ID AND ITM.EP_APPRAISAL_ID = SEC.EP_APPRAISAL_ID AND ITM.EP_ROLE = SEC.EP_ROLE AND ITM.EP_REVIEWER_ID = SEC.EP_REVIEWER_ID AND ITM.EP_SECTION_TYPE = SEC.EP_SECTION_TYPE
|