ORA-00905:CASE表达式中缺少关键字

时间:2017-05-04 18:23:40

标签: sql oracle

我收到此错误“ORA-00905:缺少关键字 00905. 00000 - “缺少关键字” *原因:
*行动: 行错误:20列:76“

尝试运行以下查询时。

WITH t as (    
SELECT tot.student_id,
tot.first_name,
tot.last_name,
tot.track_date,
MAX(track_date) over (partition by tot.student_id) as max_track_date
from student tot
inner join student_backup toov
on tot.student_id = toov.student_id
AND CASE WHEN tot.track_date IS NULL THEN SYSDATE ELSE tot.track_date between    
toov.start_dt AND toov.start_dt + toov.duration/60/40 END 
where toov.course_id=163121)
SELECT * FROM t;

请帮我解决这个问题。提前致谢

1 个答案:

答案 0 :(得分:3)

...
AND CASE WHEN tot.track_date IS NULL THEN SYSDATE ELSE tot.track_date between 
toov.start_dt AND toov.start_dt + toov.duration/60/40 END

该怎么办?您有一个CASE表达式,WHEN... THEN...,您可以使用ELSE子句。在ELSE之后,您有一个列名,然后是关键字BETWEEN。这是没有意义的。 BETWEEN是一个逻辑运算符,它在那里做什么?

进一步阅读:似乎您错放了关键字END 。它属于之前关键字BETWEEN