you will have to rewrite is as an outer join fom A and B to the subquery tables.
Also, rewrite ...
WHERE TO_CHAR(CAL_DAY_DT, 'YYYYMM') = TO_CHAR(CAL_DATE, 'YYYYMM')
... as ...
WHERE
CAL_DATE >= TRUNC(CAL_DAT_DT,'MM')
and
CAL_DATE < ADD_MONTHS(TRUNC(CAL_DAT_DT,'MM'),1)




Reply With Quote