i am not able to figure out what keyword is missing when i tried to execute below query, what i want is if startDate and endDate are present use between else return sysdate-7 data.
select * from LARGE_RELATION LR where
(CASE WHEN (STARTDATE IS NOT NULL AND ENDDATE IS NOT NULL)
THEN LR.END_DT BETWEEN to_date(STARTDATE, 'yyyymmdd') and to_date(ENDDATE, 'yyyymmdd')
ELSE (LR.END_DT IS NULL OR LR.END_DT > SYSDATE - 7)
END);
ORA-00905: missing keyword 00905. 00000 - "missing keyword" *Cause:
*Action: Error at Line: 3 Column: 31
CASE
is an statement and return a value not a condition – Juan Carlos Oropeza