左连接ORA-00918:列模糊定义错误

时间:2014-06-25 14:50:26

标签: sql oracle join

更新:我将LEFT JOIN切换为FULL JOIN并且它可以正常工作。 但是,我太新了SQL编码知道为什么......所以如果有人知道,请告诉我。谢谢!

(我正在使用Oracle SQL Developer版本4.0.2.15)
我不知道自己做错了什么,但我不能让这个Left Join工作。如果我使用"加入"然后它工作。如果我把" Left Join",我收到错误消息:

ORA-00918:列模糊定义
00918. 00000 - "列模糊定义"
*原因:
*行动:

错误发生在第一个左连接

附近
    Select fa.ABC 

    From AdminDisplay.AppointmentInfo fa  

    Left Join (  
    select info.feFpk as infoFpk  
    ,listagg(info.institution,'/ ') within group (order by rowid) as institution  
    ,listagg(info.fieldofstudy,'/ ') within group (order by rowid) as Undegradmajor  
    ,listagg(info.degreedesc,'/ ') within group (order by rowid) as Undergraddegree  

    from (select fe.ABC feFpk  
    ,fe.institution  
    ,fe.fieldofstudy  
    ,ld.degreedesc  
    from MasterDisplay.faceducation fe  
    join MasterDisplay.lkupdegree ld on ld.degreepk=fe.degreepk  
    where fe.educationtypepk in ('XXX')) info  

    group by info.feFpk  
    ) UG on UG.infoFpk=fa.ABC  
    ;  

1 个答案:

答案 0 :(得分:0)

不确定为什么从内部连接切换到外部连接会引发错误,因为它来自 UG内嵌视图中的。看起来它可能是一个解析器错误,也许。

您可以通过指定info内联视图中的两个表中哪一个提供rowid来避免外连接错误,因为@Amir排序建议:

Left Join (  
select info.feFpk as infoFpk  
,listagg(info.institution,'/ ') within group (order by fe_rowid) as institution  
,listagg(info.fieldofstudy,'/ ') within group (order by fe_rowid) as Undegradmajor  
,listagg(info.degreedesc,'/ ') within group (order by fe_rowid) as Undergraddegree  

from (select fe.rowid fe_rowid
,fe.ABC feFpk  
,fe.institution  
,fe.fieldofstudy  
,ld.degreedesc  
from MasterDisplay.faceducation fe  
join MasterDisplay.lkupdegree ld on ld.degreepk=fe.degreepk  
where fe.educationtypepk in ('XXX')) info  

group by info.feFpk  
) UG

因此,在内联视图中,我在选择列表中添加了fe.rowid fe_rowid作为额外项目;然后listagg()调用使用该别名fe_rowid而不是模糊的rowid

使用rowid命令任何东西都有点奇怪,因为它并没有真正代表任何有用的数据。如果您之所以选择它是因为您必须通过某事订购,那么您可以order by null这也是不确定的;或order by feFpk,即使它是合成密钥,它可能稍微有用。