Mohsin ALvi
Mohsin ALvi

Reputation: 61

ORA-00905: Missing keyword in CASE expression

I am getting this error "ORA-00905: missing keyword 00905. 00000 - "missing keyword" *Cause:
*Action: Error at Line: 20 Column: 76"

While trying to run the following query.

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;

Please help me regarding this. Thanks in advance

Upvotes: 1

Views: 1865

Answers (1)

user5683823
user5683823

Reputation:

...
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

What is that supposed to do? You have a CASE expression, WHEN... THEN... and you get to the ELSE clause. Right after ELSE you have a column name and then the keyword BETWEEN. That makes no sense. BETWEEN is a logical operator, what is it doing there?

On further reading: it seems you misplaced the keyword END. It belongs before the keyword BETWEEN.

Upvotes: 3

Related Questions