SQL Oracle LEFT JOIN 和 SUBQUERY 错误:ORA-00905:缺少关键字

SQL Oracle LEFT JOIN and SUBQUERY error: ORA-00905: missing keyword(SQL Oracle LEFT JOIN 和 SUBQUERY 错误:ORA-00905:缺少关键字)
本文介绍了SQL Oracle LEFT JOIN 和 SUBQUERY 错误:ORA-00905:缺少关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

就这个 ​​Oracle 查询寻求您的帮助.它给了我错误 2ORA-00905:缺少关键字".在我添加 LEFT JOIN 语句之前它工作正常.显然,如果没有 LEFT JOIN 语句,它将无法提供我们需要的信息.

Asking for your help on this Oracle query. It's giving me the error 2 "ORA-00905: missing keyword". It was working fine before I added the LEFT JOIN statement. Obviously it won't deliver the information as we need it without the LEFT JOIN statement.

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

Please provide any help to know which keyword is missing in this query

非常感谢!:

数据库表:DW.TICKETSDW.TICKET_ACTLOG

DB Tables: DW.TICKETS DW.TICKET_ACTLOG

子查询表:TABLE_RESOLVERS

Subquery table: 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

推荐答案

在 Oracle 中,我们在声明表别名时不包含 AS.而不是

In Oracle we don't include the AS when declaring a table alias. Instead of

    ) AS TABLE_RESOLVERS 

   ) TABLE_RESOLVERS 

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

This is one example when Oracle syntax is more restrictive than some other flavours of SQL. It is also inconsistent with the declaration of column aliases, which is unfortunate but almost certainly it's too complex to change this far down the road.

这篇关于SQL Oracle LEFT JOIN 和 SUBQUERY 错误:ORA-00905:缺少关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Execute complex raw SQL query in EF6(在EF6中执行复杂的原始SQL查询)
Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)