sql - 表与连接图的其余部分断开连接
问题描述
对于我对表 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 开发人员
解决方案
首先总是你明确加入,然后:
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;
推荐阅读
- reactjs - 从输入组件中获取值并在 React 中的另一个组件中使用它
- r - 从季度到年度数据
- php - 为什么我可以在 PHP5 中传递不带引号的回调函数?
- django - 如何为 WSGIPassAuthorization On 设置配置文件以在 django 中使用 apache 进行令牌身份验证
- php - 包含另一个 php 文件后页面不显示内容
- c# - Powershell 字符串插值是否支持格式说明符
- node.js - 是否可以使用 TestCafé 比较两个图像以验证确切的图像是否可用?
- c# - Telegram Bot 无法接收 preCheckoutQuery 更新
- node.js - 如果在 package.json 中不满足依赖关系,项目为什么仍然运行和构建?
- opencv - 本质分解的稳定翻译