Suppose there is a table structure like this
Name | Class | CS_ex_date | IT_ex_date|
xyz | CSE | 10 june | Null |
123 | ECE | Null | Null |
456 | MECH | Null | Null |
678 | MECH | Null | Null |
abc | IT | Null | 3 Aug |
I want to create a select statement using case expression and within case expressions are some conditions.
I have seen the usual syntax for case expressions and case expressions in where conditions, but I want to put some conditions inside the THEN part. I am having problem with the syntax.
My query is something like this:
select *
from student
where (case
when class like '%SE%'
then CS_ex_date > sysdate and CS_ex_date < sysdate + 60
when class like '%T%'
then IT_ex_date > sysdate and IT_ex_date < sysdate + 60
end);
I am not sure about the syntax of my query and getting ORA-00905: missing keyword.
The expected output should be
Name | Class | CS_ex_date | IT_ex_date|
xyz | CSE | 10 june | Null |
abc | IT | Null | 3 Aug |
Is there any way around this. That produces the same result using any other method.