Thanks for the question, AMOGH.
Asked: December 15, 2016 - 12:42 pm UTC
Last updated: December 16, 2016 - 2:25 am UTC
Version: Oracle Live SQL
Viewed 1000+ times
You Asked
select case when extract(month from birth_date) > 3
then (select * from people where to_date('3009'||(extract(year from birth_date)+1),'ddmmyyyy') < trunc(sysdate))
case when extract(month from birth_date) < 3
then (select * from people where to_date('3009'||extract(year from birth_date),'ddmmyyyy') < trunc(sysdate))
end from people
Gives a missing keyword issue, could you please tell me why?
and Connor said...
One too many "case" words
SQL> select
2 case
3 when extract(month from birth_date) > 3
4 then (select * from people where to_date('3009'||(extract(year from birth_date)+1),'ddmmyyyy') < trunc(sysdate))
5 case
6 when extract(month from birth_date) < 3
7 then (select * from people where to_date('3009'||extract(year from birth_date),'ddmmyyyy') < trunc(sysdate))
8 end
9 from people;
case
*
ERROR at line 5:
ORA-00905: missing keyword
SQL>
SQL>
SQL> select
2 case
3 when extract(month from birth_date) > 3
4 then (select * from people where to_date('3009'||(extract(year from birth_date)+1),'ddmmyyyy') < trunc(sysdate))
5 when extract(month from birth_date) < 3
6 then (select * from people where to_date('3009'||extract(year from birth_date),'ddmmyyyy') < trunc(sysdate))
7 end
8 from people;
no rows selected
Is this answer out of date? If it is, please let us know via a Comment