Ошибка ora 00920 invalid relational operator

You get this error in Oracle when you are missing a comparison operation, such as = — as John Maillet already noted.

My concern is the second part of the where clause:

where to_date(substr(COLUMN_NAME, 1, 14), 'YYYYMMDDHH24MISS') >=
                  to_date('MIN_DATE', 'YYYYMMDDHH24MISS')

You have MIN_DATE in single quotes. This is interpreted as a string with eight letters in it, starting with 'M' and ending with 'E'. This is not interpreted as a variable. Presumably you mean:

where to_date(substr(COLUMN_NAME, 1, 14), 'YYYYMMDDHH24MISS') >=
                  to_date(MIN_DATE, 'YYYYMMDDHH24MISS')

You should only use single quotes for string and date constants.

I should add that you should be able to do this comparison without having to convert to dates:

where left(COLUMN_NAME, 14) = MIN_DATE

You get this error in Oracle when you are missing a comparison operation, such as = — as John Maillet already noted.

My concern is the second part of the where clause:

where to_date(substr(COLUMN_NAME, 1, 14), 'YYYYMMDDHH24MISS') >=
                  to_date('MIN_DATE', 'YYYYMMDDHH24MISS')

You have MIN_DATE in single quotes. This is interpreted as a string with eight letters in it, starting with 'M' and ending with 'E'. This is not interpreted as a variable. Presumably you mean:

where to_date(substr(COLUMN_NAME, 1, 14), 'YYYYMMDDHH24MISS') >=
                  to_date(MIN_DATE, 'YYYYMMDDHH24MISS')

You should only use single quotes for string and date constants.

I should add that you should be able to do this comparison without having to convert to dates:

where left(COLUMN_NAME, 14) = MIN_DATE

ORA-00920

ORA-00920: неправильный реляционный оператор

Причина:

Условие поиска было введено с неправильным или пропущенным реляционным оператором.

Действие:

Включите правильный реляционный оператор такой как =, !=, ^=, <>, >, <, >=, <=, ALL, ANY, NOT BETWEEN, NOT EXISTS, NOT IN, IS NOT NULL, или NOT LIKE.

I don’t quite trust what you’re posted…

Your query should throw ORA-00979: Not a GROUP BY expression. This is because the columns not included in an analytic function, namely username are not reflected in your group by.

ORA-00920 implies that you are missing one of the following: =, <>, not in, in, !=, is not null, is null, not like, like etc. Are you sure you’ve posted the correct query?

In 11.2, creating something that approximates your table, like so:

create table host
(  username varchar2(100)
 , created_dt date );

 insert into host
 select level, sysdate - level
   from dual
connect by level <= 10
        ;

 insert into host
 select chr(ascii(level) + 32), sysdate - level
   from dual
connect by level <= 10
        ;
 commit ;

and then running the query posted results in ORA-00979. Changing this to the following work’s fine.:

select case when regexp_like(username, '^d+$') then 'GRP_OTHERS'
            else username end as username
     , count(*)
  from host
 where created_dt between
       to_date('2012-may-23 00:00:00', 'yyyy-mon-dd hh24:mi:ss') and
       to_date('2012-may-23 23:59:59', 'yyyy-mon-dd hh24:mi:ss')
 group by case when regexp_like(username, '^d+$') then 'GRP_OTHERS'
               else username end
       ;

This can alternatively be re-written as:

select distinct username
     , count(*) over ( partition by case when regexp_like(username, '^d+$') 
                                               then 'GRP_OTHERS'
                                          else username end )
  from host
 where created_dt between
       to_date('2012-may-23 00:00:00', 'yyyy-mon-dd hh24:mi:ss') and
       to_date('2012-may-23 23:59:59', 'yyyy-mon-dd hh24:mi:ss')

I think this second query is more like what you want. It returns the actual user-name, but groups all those that are just digits together. Just replace the username column returned by the case if you want to see GRP_OTHERS instead.

It’s slightly better not to use the mon format model in Oracle as it’s not, necessarily, consistent across languages. Use mm instead.


As you’re using 9i you can use translate instead. Replace the regexes with:

trim(translate(username,'0123456789',' ')) is null

This replaces numbers with nothing and then checks to see if there’s anything left…

totn Oracle Error Messages


Learn the cause and how to resolve the ORA-00920 error message in Oracle.

Description

When you encounter an ORA-00920 error, the following error message will appear:

  • ORA-00920: invalid relational operator

Cause

You tried to execute a SQL statement, but the WHERE clause contained an invalid relational operator.

Resolution

The option(s) to resolve this Oracle error are:

Option #1

Correct the WHERE clause. Valid relational operators are as follows:

=
!=
^=
<>
<
<=
>
>=
ALL
ANY
BETWEEN
NOT BETWEEN
EXISTS
NOT EXISTS
IN
NOT IN
IS NULL
IS NOT NULL
LIKE
NOT LIKE

  • Ошибка ora 00054 resource busy and acquire with nowait specified or timeout expired
  • Ошибка ora 00001 unique constraint violated
  • Ошибка or tapsh 08 при добавлении карты гугл pay
  • Ошибка or pmia 14 что это
  • Ошибка origin nfs 2016