U zoekt een gefilterd aggregaat:
SELECT COUNT(DISTINCT
case when
MODIFIED_DATE BETWEEN TO_DATE('{RUN_DATE_YYYYMMDD}','YYYYMMDD') - 56
AND TO_DATE('{RUN_DATE_YYYYMMDD}','YYYYMMDD') - 49
then CASE_ID
end) as c1,
COUNT(DISTINCT
case when
MODIFIED_DATE BETWEEN TO_DATE('{RUN_DATE_YYYYMMDD}','YYYYMMDD')-49
AND TO_DATE('{RUN_DATE_YYYYMMDD}','YYYYMMDD')-42
then CASE_ID
end) as c2
from t1
WHERE MODIFIED_DATE
BETWEEN TO_DATE('{RUN_DATE_YYYYMMDD}','YYYYMMDD') - 56
AND TO_DATE('{RUN_DATE_YYYYMMDD}','YYYYMMDD') - 42
Merk op dat de WHERE
clausule moet nu beide intervallen dekken.