/* Calendar Group ID chosen from the calculated IDs which had been produced the reports, and the id will not be the submitted OR saved. */ SELECT B.OPRID ,A.CAL_RUN_ID ,A.DESCR FROM PS_GP_CAL_RUN A ,PS_GP_OPR_RULE_PRF B , PS_GPCN_RW_GEN G WHERE (B.USED_BY = 'A' OR (B.USED_BY = 'C'AND A.COUNTRY = B.COUNTRY)) AND (EXISTS ( SELECT 'X' FROM PS_GP_CAL_RUN_DTL DTL WHERE A.CAL_RUN_ID = DTL.CAL_RUN_ID AND DTL.CALC_TYPE = 'P') OR EXISTS ( SELECT 'X' FROM PS_GP_CAL_RUN_OFF DT2 WHERE A.CAL_RUN_ID = DT2.CAL_RUN_ID )) AND A.CAL_RUN_ID = G.GPCN_SRC_CAL_RN_ID AND G.PROCESS_INSTANCE = ( SELECT MAX (G2.PROCESS_INSTANCE) FROM PS_GPCN_RW_GEN G2 WHERE G2.GPCN_SRC_CAL_RN_ID = A.CAL_RUN_ID)
|