oracle – ORA-01799:一个列可能没有外连到子查询

前端之家收集整理的这篇文章主要介绍了oracle – ORA-01799:一个列可能没有外连到子查询前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我的查询
SELECT 
    COUNT(C.SETID)
FROM 
    MYCUSTOMER C
    LEFT OUTER JOIN MYCUSTOPTION CO 
    ON 
        (C.SETID = CO.SETID 
            AND C.CUST_ID = CO.CUST_ID 
            AND CO.effdt = ( 
                SELECT MAX(COI.EFFDT) 
                FROM MYCUSTOPTION COI 
                WHERE 
                    COI.SETID = CO.SETID 
                                    AND COI.CUST_ID = CO.CUST_ID 
                                    AND COI.EFFDT <=SYSDATE    
                )
    )

这里是我正在收到的错误信息..

我究竟做错了什么???

您可以通过推动子查询来重写它,使其不外部连接:
select Count(C.setid)
  from mycustomer C
       left outer join (select *
                          from mycustoption co
                         where co.effdt <= (select Max(COI.effdt)
                                              from mycustoption COI
                                             where COI.setid = co.setid
                                               and COI.cust_id = co.cust_id
                                               and COI.effdt <= sysdate)) co
                    on ( C.setid = CO.setid
                         and C.cust_id = CO.cust_id )
原文链接:https://www.f2er.com/oracle/205468.html

猜你在找的Oracle相关文章