school superintendent wants a policy where absences are escalated after five school days if a kid does not bring an excuse. Every date function I try will only count calendar days, not in-session school days. I can do this
SELECT rownum rn, date_value
FROM (SELECT Date_Value FROM Calendar_Day cd WHERE cd.InSession != 0 and schoolid=7
AND cd.Date_Value >= '05-SEP-13' ORDER BY Date_Value)
and get a list of in-session days with row numbers. Now how to use it? Have tried
with HSRN as (SELECT rownum rn, date_value
FROM (SELECT Date_Value FROM Calendar_Day cd WHERE cd.InSession != 0 and schoolid=7
AND cd.Date_Value >= '05-SEP-13' ORDER BY Date_Value))
select max(hsrn.rn) from hsrn
where hsrn.date_value <= trunc(sysdate)
and I can get a row number for today's date, but Oracle will not let me pass back a rownumber. Can I get a list of dates where rownum <= max(hsrn.rn) ? I get an error that group functions are not allowed when I try that in other subqueries.
Thanks.
SELECT rownum rn, date_value
FROM (SELECT Date_Value FROM Calendar_Day cd WHERE cd.InSession != 0 and schoolid=7
AND cd.Date_Value >= '05-SEP-13' ORDER BY Date_Value)
and get a list of in-session days with row numbers. Now how to use it? Have tried
with HSRN as (SELECT rownum rn, date_value
FROM (SELECT Date_Value FROM Calendar_Day cd WHERE cd.InSession != 0 and schoolid=7
AND cd.Date_Value >= '05-SEP-13' ORDER BY Date_Value))
select max(hsrn.rn) from hsrn
where hsrn.date_value <= trunc(sysdate)
and I can get a row number for today's date, but Oracle will not let me pass back a rownumber. Can I get a list of dates where rownum <= max(hsrn.rn) ? I get an error that group functions are not allowed when I try that in other subqueries.
Thanks.