SELECT DISTINCT A.EMPLID , A.EMPL_RCD , A.ACA_GRP_ID , A.NAME , A.FIRST_NAME , A.LAST_NAME , A.ACA_WEEK , A.COMPANY , A.ACA_WEEKLY_TOT + CASE WHEN ( SELECT T.ACA_WEEKLY_TOT FROM PS_ACA_WEEKLY_TL T WHERE T.EMPLID = A.EMPLID AND T.EMPL_RCD = A.EMPL_RCD AND T.ACA_GRP_ID = A.ACA_GRP_ID AND T.ACA_WEEK = A.ACA_WEEK AND T.COMPANY = A.COMPANY) <> 0 THEN ( SELECT T.ACA_WEEKLY_TOT FROM PS_ACA_WEEKLY_TL T WHERE T.EMPLID = A.EMPLID AND T.EMPL_RCD = A.EMPL_RCD AND T.ACA_GRP_ID = A.ACA_GRP_ID AND T.ACA_WEEK = A.ACA_WEEK AND T.COMPANY = A.COMPANY) ELSE 0.00 END ACA_WEEKLY_TOT, ( SELECT SUM(B.ACA_WEEKLY_TOT) FROM PS_ACA_WEEKLY_JOB B WHERE B.EMPLID = A.EMPLID AND B.ACA_GRP_ID = A.ACA_GRP_ID AND B.COMPANY = A.COMPANY AND B.ACA_WEEK = A.ACA_WEEK) + CASE WHEN ( SELECT SUM(B2.ACA_WEEKLY_TOT) FROM PS_ACA_WEEKLY_TL B2 WHERE B2.EMPLID = A.EMPLID AND B2.ACA_GRP_ID = A.ACA_GRP_ID AND B2.ACA_WEEK = A.ACA_WEEK) <> 0 THEN ( SELECT SUM(B3.ACA_WEEKLY_TOT) FROM PS_ACA_WEEKLY_TL B3 WHERE B3.EMPLID = A.EMPLID AND B3.ACA_GRP_ID = A.ACA_GRP_ID AND B3.ACA_WEEK = A.ACA_WEEK) ELSE 0.00 END ACA_WEEKLY_TOT_2, A.ACA_PERIOD FROM PS_ACA_WEEKLY_JOB A
|