COUNT(CASE
WHEN DAYS_BETWEEN(ROUND_DAY(<%= Earlier_Date %>),ROUND_DAY(CASE WHEN TO_TIMESTAMP('<%=date_to%> 23:59:59', 'YYYY-MM-DD HHSS') > TODAY()
THEN TODAY()
WHEN TO_TIMESTAMP('<%=date_to%> 23:59:59', 'YYYY-MM-DD HHSS') <= TODAY()
THEN TO_TIMESTAMP('<%=date_to%> 23:59:59', 'YYYY-MM-DD HHSS')
ELSE TODAY()
END)) > 60
THEN "CASES"."_CASE_KEY"
ELSE NULL END)/COUNT("Total Average"."Total")