ORA-00936: 缺少表达式 oracle

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22582103/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 02:17:35  来源:igfitidea点击:

ORA-00936: missing expression oracle

sqldatabaseoracleexpressionora-00936

提问by garuda

I have this query

我有这个查询

SELECT DAL_ROWNOTABLE.DAL_ID FROM 
(
    SELECT ticket.id AS "DAL_ID",  ROWNUMBER ( Order By ticket.id  )  AS "DAL_ROWNUMBER" 
    FROM ticket_table ticket 
    WHERE ( ticket.type = N'I' ) 
    AND 
    ( 
        ticket.tenant IS NULL OR ticket.tenant IN 
        (
            SELECT  * FROM 
            ( 
                SELECT tenant_group_member.tenant_id 
                FROM tenant_group_member 
                WHERE tenant_group_member.tenant_group = HEXTORAW('30B0716FEB5F4E4BB82A7B7AA3A1A42C') 
                ORDER BY ticket.id 
            ) 
         ) 
     )
) DAL_ROWNOTABLE 
WHERE DAL_ROWNOTABLE.DAL_ROWNUMBER BETWEEN 1 AND 21

What is the problem with the allow query that is throwing ORA-00936 missing expression? anyone? Any help will be appreciated...Error thrown at column:80 which is at the beginning of first order by:

抛出 ORA-00936 缺失表达式的允许查询有什么问题?任何人?任何帮助将不胜感激...在列:80 处抛出错误,该列位于第一顺序的开头:

采纳答案by Gordon Linoff

Your query can be much simplified. It has things like extra layers of subqueries and an unnecessary order byin an insubquery. What you want to do with rownumberyou can do with just rownum:

您的查询可以大大简化。它有类似的事情的子查询额外的层和不必要order by的一个in子查询。你想做什么,rownumber你可以只做rownum

SELECT DAL_ROWNOTABLE.DAL_ID
FROM (SELECT ticket.id AS "DAL_ID" 
      FROM ticket_table ticket 
      WHERE (ticket.type = N'I' ) AND 
            (ticket.tenant IS NULL OR
             ticket.tenant IN (SELECT tgm.tenant_id 
                               FROM tenant_group_member tgm
                               WHERE tgm.tenant_group = HEXTORAW('30B0716FEB5F4E4BB82A7B7AA3A1A42C') 
                              ) 
            )
      ORDER BY ticket.id
     ) DAL_ROWNOTABLE 
WHERE rownum <= 21;

回答by APC

ORA-00936 usually indicates a syntax error.

ORA-00936 通常表示语法错误。

ROWNUMBERis not an Oracle function. Unless you have a user-defined function of that name I suspect the function you're looking for is ROW_NUMBER().

ROWNUMBER不是 Oracle 函数。除非您有该名称的用户定义函数,否则我怀疑您要查找的函数是ROW_NUMBER().