2

我有这个查询

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

引发 ORA-00936 缺失表达式的允许查询有什么问题?任何人?任何帮助将不胜感激......在列:80 抛出错误,这是在第一个订单的开头:

4

2 回答 2

2

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

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

于 2014-03-22T19:08:20.420 回答
0

您的查询可以大大简化。它有额外的子查询层和子查询中不必要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;
于 2014-03-22T19:34:53.397 回答