首页 > 解决方案 > 表与连接图的其余部分断开连接

问题描述

对于我对表 1 的以下查询,我收到错误

“与连接图的其余部分断开连接。”

我过去遇到过这个问题,只是简单地重新排序了表引用以及标识符,并且已经修复了它。但是,我似乎无法以这种方式解决它。

select *
from (
  select table1.*, table2.*, table3.*, 
  row_number() over (partition by table1.date1,
        table1.PRODUCT_DESC,
        table1.PRODUCT_SUB_TYPE_CD,
        table3.TYPE_CPY,
        table3.entity order by table1.PRODUCT_DESC) as rn
    from table1, table2, table3
) x
where rn <= 3
and x.code1 = x.code2 
and x.account_key = x.code1
and table1.date1 between '01-APR-19' and '01-APR-21'
and x.PRODUCT_DESC = 'text'
and x.PRODUCT_SUB_TYPE_CD = 'text'
and  x.TYPE_CPY = 'text'
and x.entity = 'N'
order by x.PRODUCT_DESC;

*注意:我正在使用 Oracle SQL 开发人员

标签: sqloracledebuggingjoin

解决方案


首先总是你明确加入,然后:

select *
from (
  select table1.*, table2.*, table3.*, 
  row_number() over (partition by table1.date1,
        table1.PRODUCT_DESC,
        table1.PRODUCT_SUB_TYPE_CD,
        table3.TYPE_CPY,
        table3.entity order by table1.PRODUCT_DESC) as rn
    from table1
    join table2 on table1.code = table2.code -- ?
    join table3 on table3.code = table1.code -- ?
) x
where rn <= 3
and x.account_key = x.cod
and x.date1 between '01-APR-19' and '01-APR-21'
and x.PRODUCT_DESC = 'text'
and x.PRODUCT_SUB_TYPE_CD = 'text'
and x.TYPE_CPY = 'text'
and x.entity = 'N'
order by x.PRODUCT_DESC;

推荐阅读