Oracle 案例缺少关键字

Oracle case missing keyword

当我尝试执行以下查询时,我无法弄清楚缺少什么关键字,我想要的是如果 startDate 和 endDate 在其他 return sysdate-7 数据之间使用。

    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

两个日期都不为空时的第一个条件句柄

第二个在其中一个日期为空时进行验证

select * 
from LARGE_RELATION LR 
where
    (    STARTDATE IS NOT NULL 
     AND ENDDATE IS NOT NULL
     AND LR.END_DT BETWEEN to_date(STARTDATE, 'yyyymmdd') 
                       AND to_date(ENDDATE, 'yyyymmdd')
    ) OR
    (     (STARTDATE IS NULL OR ENDDATE IS NULL)
      AND (LR.END_DT IS NULL OR LR.END_DT > SYSDATE - 7)
    ) 

您需要在case之后指定您要检查的参数 在你的例子中 - CASE STARTDATE WHEN IS NOT NULL AND (ENDDATE IS NOT NULL)