sql - SAS to Oracle: ORA-00920: invalid relational operator -


running code in sas oracle:

rsubmit; proc sql;     &c_oradb;     create table immb     select * connection oracle     (select b.id, b.sysdate,      case when id>0 'imm' end source /*creating  variable label source file */     hpmdcd a, omdb.medta b     a.code=b.code     ,   '1/1/2008'd =< sysdate <= '12/31/2016'd      order id, sysdate);     disconnect oracle; quit; 

i following error:

error: oracle prepare error: ora-00920: invalid relational operator. sql statement

and   '1/1/2008'd =< sysdate <= '12/31/2016'd  

there 3 things wrong statement.

  1. you can't use 2 relational operators together. use between
  2. d after date not required work column alias may needed in select not while comparing.
  3. comparing string date not correct.

use

and sysdate between date '2008-01-01' , date '2016-12-31' 

date '2008-01-01' equivalent to_date('2008-01-01','yyyy-mm-dd')

also, although won't give error, instead of using classing comma separated tables, use proper join syntax. like.

from table1 t1 join table2 t2    on t1.somecolumn=t2.somecolumn 

i looking sql query. not sure on sas part.


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -