13

请求您对此 Oracle 查询的帮助。它给了我错误 2“ORA-00905:缺少关键字”。在我添加 LEFT JOIN 语句之前它工作正常。显然,如果没有 LEFT JOIN 语句,它不会提供我们需要的信息。

请提供任何帮助以了解此查询中缺少哪个关键字

非常感谢!:

数据库表:DW.TICKETS DW.TICKET_ACTLOG

子查询表:TABLE_RESOLVERS

SELECT 
    TO_CHAR(DW.TICKETS.RESOLVED_TIMESTAMP,'YYYY-MM-DD HH24:MI:SS') AS RESOLVED_DATE, 
    DW.TICKETS.SUBJECT, DW.TICKETS.OWNER_CORE_ID, 
    DW.TICKETS.TICKET_NUMBER, 
    TABLE_RESOLVERS.SUBMITTER AS RESOLVER_CORE_ID 

FROM DW.TICKETS 

LEFT JOIN
    (SELECT 
        TICKET_NUMBER,
        SUBMITTER 
    FROM DW.TICKET_ACTLOG 
    WHERE 
        TYPE = 'Final Resolution' AND 
        (SUBMITTER = 'B02666' OR 
        SUBMITTER = 'R66604') 
    ORDER BY CREATE_TIMESTAMP DESC 
    ) AS TABLE_RESOLVERS 

ON DW.TICKETS.TICKET_NUMBER = TABLE_RESOLVERS.TICKET_NUMBER  

WHERE 
    DW.TICKETS.RESOLVED_TIMESTAMP >= to_date('05-03-2010','dd-mm-yyyy') AND 
    DW.TICKETS.RESOLVED_TIMESTAMP < to_date('8-03-2010','dd-mm-yyyy') AND 
    DW.TICKETS.TICKET_NUMBER LIKE 'TCK%' AND 
    DW.TICKETS.TICKET_NUMBER IN 
        (SELECT TICKET_NUMBER 
        FROM DW.TICKET_ACTLOG 
        WHERE 
            (SUBMITTER = 'B02666' OR 
            SUBMITTER = 'R66604') 
        ) 

ORDER BY DW.TICKETS.CREATE_TIMESTAMP ASC
4

2 回答 2

32

AS在 Oracle 中,我们在声明表别名时不包括。代替

    ) AS TABLE_RESOLVERS 

   ) TABLE_RESOLVERS 

这是 Oracle 语法比其他一些 SQL 风格更具限制性的一个示例。它也与列别名的声明不一致,这是不幸的,但几乎可以肯定的是,在未来改变这一点太复杂了。

于 2010-04-02T20:12:49.770 回答
2

It seems like the "AS" is extraneous near "AS TABLE_RESOLVERS"

于 2010-04-02T20:16:48.313 回答