We have a new software system in which we are allow to write SQL programs to pull user information. We need a SQL that on Monday the system date(selection) will automatic back date 3 days to previous Friday/ Selection on Sunday would back up 2 days to the previous Friday. Not having a lot of success. Any help we would be thankful. Code below:
CASE WHEN TO_CHAR(sysdate, 'fmday') = 'sunday' THEN sysdate - 2
WHEN TO_CHAR(sysdate, 'fmday') = 'monday' THEN sysdate - 3
ELSE sysdate - 1
where alert_cd = 'AUTO'
and chg_dtm >= sysdate
If we can get this basic SQL working it should be easier in the future.