SELECT JOB.HRS_JOB_OPENING_ID , OPR.OPRID , JOB.HRS_PRM_PST_TITLE , 0 , CASE WHEN ( SELECT B.HRS_JO_PST_OPN_DT FROM PS_HRS_JO_PST_DST B WHERE JOB.HRS_JOB_OPENING_ID = B.HRS_JOB_OPENING_ID AND B.HRS_JO_PST_SEQ = 0 AND B.HRS_SEQ_NUM = 0 AND (B.HRS_JO_PST_OPN_DT IS NULL OR B.HRS_JO_PST_OPN_DT = ( SELECT MIN(B1.HRS_JO_PST_OPN_DT) FROM PS_HRS_JO_PST_DST B1 WHERE JOB.HRS_JOB_OPENING_ID = B1.HRS_JOB_OPENING_ID AND B.HRS_JO_PST_SEQ = B1.HRS_JO_PST_SEQ))) IS NOT NULL THEN %Sql(FUNCLIB_HRS_DATE_DIFF,(SELECT B.HRS_JO_PST_OPN_DT FROM PS_HRS_JO_PST_DST B WHERE JOB.HRS_JOB_OPENING_ID = B.HRS_JOB_OPENING_ID AND B.HRS_JO_PST_SEQ = 0 AND B.HRS_SEQ_NUM = 0 AND (B.HRS_JO_PST_OPN_DT IS NULL OR B.HRS_JO_PST_OPN_DT = ( SELECT MIN(B1.HRS_JO_PST_OPN_DT) FROM PS_HRS_JO_PST_DST B1 WHERE JOB.HRS_JOB_OPENING_ID = B1.HRS_JOB_OPENING_ID AND B.HRS_JO_PST_SEQ = B1.HRS_JO_PST_SEQ))), (JOB.CLOSE_DT)) ELSE %Sql(FUNCLIB_HRS_DATE_DIFF, JOB.OPEN_DT, JOB.CLOSE_DT) END , %Sql(FUNCLIB_HRS_DATE_YEAR,JOB.STATUS_DT)%Concat '-' %Concat %Sql(FUNCLIB_HRS_DATE_MONTH,JOB.STATUS_DT) FROM PS_HRS_JO_TEAM TM , PS_BUS_UNIT_TBL_HR BU, PS_HRS_JOB_OPENING JOB, PS_HRS_PE_OPR_FLCT FLCT, PSOPRDEFN OPR WHERE JOB.HRS_JOB_OPENING_ID = TM.HRS_JOB_OPENING_ID AND JOB.STATUS_CODE = ( SELECT STS.STATUS_CODE FROM PS_HRS_STS_TBL STS WHERE STS.STATUS_AREA = '1' AND STS.COMPLETE_STS_IND = 'Y') AND JOB.HRS_OPENING_LIMIT = 'L' AND JOB.HRS_JO_TYPE = 'R' AND TM.HRS_JO_TM_TYPE IN ('M', 'R') AND JOB.CLOSE_DT IS NOT NULL AND BU.BUSINESS_UNIT = JOB.BUSINESS_UNIT AND JOB.STATUS_DT BETWEEN FLCT.FROM_DATE AND FLCT.TO_DATE AND OPR.OPRID = FLCT.OPRID AND TM.EMPLID = OPR.EMPLID
|