I have a table with dates populated from last 10 years & next 20 years. I want to calculate if the date is in last 7 working (week) days with reference to today (sysdate) as shown in the sample table below (populate last column IsInLast7WorkingDays).
Assumption: Saturday & Sunday are non-working days.
TODAY CAL_DATE ISWEEKDAY IsInLast7WorkingDays
8/12/2021 8/1/2021 N N
8/12/2021 8/2/2021 Y N
8/12/2021 8/3/2021 Y Y
8/12/2021 8/4/2021 Y Y
8/12/2021 8/5/2021 Y Y
8/12/2021 8/6/2021 Y Y
8/12/2021 8/7/2021 N N
8/12/2021 8/8/2021 N N
8/12/2021 8/9/2021 Y Y
8/12/2021 8/10/2021 Y Y
8/12/2021 8/11/2021 Y Y
8/12/2021 8/12/2021 Y N
8/12/2021 8/13/2021 Y N
8/12/2021 8/14/2021 N N
8/12/2021 8/15/2021 N N
8/12/2021 8/16/2021 Y N
8/12/2021 8/17/2021 Y N
8/12/2021 8/18/2021 Y N
8/12/2021 8/19/2021 Y N
8/12/2021 8/20/2021 Y N
TODAY CAL_DATE ISWEEKDAY IsInLast7WorkingDays
8/14/2021 8/1/2021 N N
8/14/2021 8/2/2021 Y N
8/14/2021 8/3/2021 Y N
8/14/2021 8/4/2021 Y N
8/14/2021 8/5/2021 Y Y
8/14/2021 8/6/2021 Y Y
8/14/2021 8/7/2021 N N
8/14/2021 8/8/2021 N N
8/14/2021 8/9/2021 Y Y
8/14/2021 8/10/2021 Y Y
8/14/2021 8/11/2021 Y Y
8/14/2021 8/12/2021 Y Y
8/14/2021 8/13/2021 Y Y
8/14/2021 8/14/2021 N N
8/14/2021 8/15/2021 N N
8/14/2021 8/16/2021 Y N
8/14/2021 8/17/2021 Y N
8/14/2021 8/18/2021 Y N
8/14/2021 8/19/2021 Y N
8/14/2021 8/20/2021 Y N
Thanks in advance.
Edit: I guess I should have mentioned that I already have a table populated with dates and "isweekday". Today is derived from sysdate in the below query.
select b.today, a.cal_date, a.isweekday
from DATE_SRK a, (select trunc(sysdate)+4 today from dual) b
order by a.cal_date;