1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
| SELECT
a.DT_DIM_FK as DT_DIM_FK,
a.ST_DIM_FK as ST_DIM_FK,
a.GEO_DIM_FK as GEO_DIM_FK,
a.PRIM_CO_DIM_FK as PRIM_CO_DIM_FK,
a.PRIM_IN_DIM_FK as PRIM_IN_DIM_FK,
a.FTE_DIM_FK as FTE_DIM_FK,
a.STAT_DIM_PR_FK as STAT_DIM_PR_FK,
a.STAT_DIM_RE_FK as STAT_DIM_RE_FK,
a.STAT_DIM_ST_FK as STAT_DIM_ST_FK,
a.PR_DATES_DIM_FK as PR_DATES_DIM_FK,
a.RE_DATES_DIM_FK as RE_DATES_DIM_FK,
a.ST_DATES_DIM_FK as ST_DATES_DIM_FK,
a.SJ_REQ_NUM as SJ_REQ_NUM,
a.SJ_REQ_SPR_NUM as SJ_REQ_SPR_NUM,
a.SJ_CMT_NUM as SJ_CMT_NUM,
a.SJ_CMT_SPR_NUM as SJ_CMT_SPR_NUM,
a.SJ_INI_EXP_NUM as SJ_INI_EXP_NUM,
a.SJ_EXP_NUM as SJ_EXP_NUM,
a.SJ_EXP_SPR_NUM as SJ_EXP_SPR_NUM,
a.SJ_EXP_SPR_BASELINE_NUM as SJ_EXP_SPR_BASELINE_NUM,
a.SJ_CNS_NUM as SJ_CNS_NUM,
a.SJ_ACT_MAX_NUM as SJ_ACT_MAX_NUM,
a.SJ_ACT_LAST_NUM as SJ_ACT_LAST_NUM,
a.SJ_SCR_NUM as S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NUM,
a.SJ_CUM_RE_INI_EXP_NUM as SJ_CUM_RE_INI_EXP_NUM,
a.dt_iso_wkofyr_nr as dt_iso_wkofyr_nr,
a.dt_iso_yr_nr as dt_iso_yr_nr,
T_CT_F_SITE_WK_ENROLL.ST_WK_FACTS_PK as ST_WK_FACTS_PK
FROM
(
SELECT
T_CT_D_DATE.DT_WKOFYR_NR AS DT_DIM_FK,
T_CT_F_SITE_ENROLL.ST_DIM_FK as ST_DIM_FK,
MAX(T_CT_F_SITE_ENROLL.GEO_DIM_FK) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS GEO_DIM_FK,
MAX(T_CT_F_SITE_ENROLL.PRIM_CO_DIM_FK) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS PRIM_CO_DIM_FK,
MAX(T_CT_F_SITE_ENROLL.PRIM_IN_DIM_FK) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS PRIM_IN_DIM_FK,
MAX(T_CT_F_SITE_ENROLL.FTE_DIM_FK) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS FTE_DIM_FK,
MAX(T_CT_F_SITE_ENROLL.STAT_DIM_PR_FK) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS STAT_DIM_PR_FK,
MAX(T_CT_F_SITE_ENROLL.STAT_DIM_RE_FK) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS STAT_DIM_RE_FK,
MAX(T_CT_F_SITE_ENROLL.STAT_DIM_ST_FK) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS STAT_DIM_ST_FK,
MAX(T_CT_F_SITE_ENROLL.PR_DATES_DIM_FK) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS PR_DATES_DIM_FK,
MAX(T_CT_F_SITE_ENROLL.RE_DATES_DIM_FK) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS RE_DATES_DIM_FK,
MAX(T_CT_F_SITE_ENROLL.ST_DATES_DIM_FK) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS ST_DATES_DIM_FK,
MAX(T_CT_F_SITE_ENROLL.SJ_REQ_NUM) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS SJ_REQ_NUM,
SUM(T_CT_F_SITE_ENROLL.SJ_REQ_SPR_NUM) AS SJ_REQ_SPR_NUM,
MAX(T_CT_F_SITE_ENROLL.SJ_CMT_NUM) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS SJ_CMT_NUM,
SUM(T_CT_F_SITE_ENROLL.SJ_CMT_SPR_NUM) AS SJ_CMT_SPR_NUM,
MAX(T_CT_F_SITE_ENROLL.SJ_INI_EXP_NUM) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS SJ_INI_EXP_NUM,
MAX(T_CT_F_SITE_ENROLL.SJ_EXP_NUM) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS SJ_EXP_NUM,
SUM(CASE
WHEN ((TRUNC(T_CT_D_DATE.DT_DATE) >= T_CT_D_SITE.ST_FSJ_ENR_EXDT) AND (TRUNC(T_CT_D_DATE.DT_DATE) <= T_CT_D_SITE.ST_LSJ_ENR_EXDT))
THEN T_CT_F_SITE_ENROLL.SJ_EXP_SPR_NUM
ELSE 0
END) AS SJ_EXP_SPR_NUM,
SUM(CASE
WHEN ((TRUNC(T_CT_D_DATE.DT_DATE) >= T_CT_D_SITE.ST_FSJ_ENR_PLDT) AND (TRUNC(T_CT_D_DATE.DT_DATE) <= T_CT_D_SITE.ST_LSJ_ENR_PLDT))
THEN T_CT_F_SITE_ENROLL.SJ_EXP_SPR_BASELINE_NUM
ELSE 0
END) AS SJ_EXP_SPR_BASELINE_NUM,
SUM(T_CT_F_SITE_ENROLL.SJ_CNS_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F_SITE_ENROLL.ST_REC_NUM) AS ST_REC_NUM,
MAX(T_CT_F_SITE_ENROLL.PR_CTMS_STAT) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS PR_CTMS_STAT,
MAX(T_CT_F_SITE_ENROLL.RE_CTMS_STAT) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS RE_CTMS_STAT,
MAX(T_CT_F_SITE_ENROLL.ST_CTMS_STAT) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS ST_CTMS_STAT,
SYSDATE as CT_TIMESTAMP,
MAX(T_CT_F_SITE_ENROLL.sj_cum_cns_num) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS SJ_CUM_CNS_NUM,
MAX(T_CT_F_SITE_ENROLL.sj_cum_scr_num) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS SJ_CUM_SCR_NUM,
MAX(T_CT_F_SITE_ENROLL.sj_cum_enr_num) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS SJ_CUM_ENR_NUM,
MAX(T_CT_F_SITE_ENROLL.sj_cum_cmp_num) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS SJ_CUM_CMP_NUM,
MAX(T_CT_F_SITE_ENROLL.sj_cum_scf_num) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS SJ_CUM_SCF_NUM,
MAX(T_CT_F_SITE_ENROLL.sj_cum_etr_num) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS SJ_CUM_ETR_NUM,
MAX(T_CT_F_SITE_ENROLL.sj_cum_dtr_num) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS SJ_CUM_DTR_NUM,
MAX(T_CT_F_SITE_ENROLL.sj_cum_fup_num) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS SJ_CUM_FUP_NUM,
MAX(T_CT_F_SITE_ENROLL.sj_cum_pr_cmt_num) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS SJ_CUM_PR_CMT_NUM,
MAX(T_CT_F_SITE_ENROLL.sj_cum_pr_exp_num) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS SJ_CUM_PR_EXP_NUM,
MAX(T_CT_F_SITE_ENROLL.sj_cum_pr_ini_exp_num) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS SJ_CUM_PR_INI_EXP_NUM,
MAX(T_CT_F_SITE_ENROLL.sj_cum_re_exp_num) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS SJ_CUM_RE_EXP_NUM,
MAX(T_CT_F_SITE_ENROLL.sj_cum_re_ini_exp_num) KEEP(DENSE_RANK LAST ORDER BY T_CT_D_DATE.DT_DATE) AS SJ_CUM_RE_INI_EXP_NUM,
MAX(T_CT_D_DATE.dt_iso_wkofyr_nr) AS dt_iso_wkofyr_nr,
MAX(T_CT_D_DATE.dt_iso_yr_nr) AS dt_iso_yr_nr
FROM
T_CT_F_SITE_ENROLL,
T_CT_D_DATE,
T_CT_D_SITE
WHERE
T_CT_D_DATE.DT_DIM_PK = T_CT_F_SITE_ENROLL.DT_DIM_FK
AND T_CT_F_SITE_ENROLL.ST_DIM_FK in (select distinct(T_CT_F_SITE_ENROLL.ST_DIM_FK) from T_CT_F_SITE_ENROLL where trunc(ct_timestamp) > (select trunc(WK_PART_AGG_LST_UPDT) from CT.T_CT_ODS_STATUS))
AND T_CT_F_SITE_ENROLL.ST_DIM_FK = T_CT_D_SITE.ST_DIM_PK
AND T_CT_D_DATE.dt_date > sysdate - 180
GROUP BY
T_CT_D_DATE.DT_WKOFYR_NR,
T_CT_F_SITE_ENROLL.ST_DIM_FK
) a left outer join T_CT_F_SITE_WK_ENROLL on (a.ST_DIM_FK=T_CT_F_SITE_WK_ENROLL.ST_DIM_FK and a.DT_DIM_FK = T_CT_F_SITE_WK_ENROLL.DT_DIM_AK) |
Partager