sql - ORA-00933: SQL 命令未在表别名上正确结束
问题描述
有问题让这个工作。每个查询都单独工作,但是当我尝试为每个子查询设置别名以使用 Join 时,我收到错误:
SQL 命令未正确结束。任何建议将不胜感激。
Select C.*
From
(
(
Select
a.*,
Row_Number() Over(Partition By referral_id Order By start_date,line) as rn
from hcclsc.referral_Bed_Day a
) A
Inner Join (
Select
a.referral_id,
max(rn) as vn
From (
Select
referral_id,
line,
bed_day_type_id,
start_date,
end_date,
Row_Number() Over(Partition by referral_id Order By start_date, line) as rn
From HCCLSC.referral_Bed_Day
) a
Group by referral_id
) B
On A.referral_ID = B.referral_id and a.rn = b.vn
) C
解决方案
You're joining A to B, but then not selecting a anything from those joined subqueries.
This part:
Select C.*
From
(
(
would need to specify columns to select from the join; if you want all of them from both subqueries then:
Select C.*
From
(
Select *
From
(
but then that extra level of subquery isn't really adding anything, and you can remove the C
level:
Select *
From
(
Select
a.*,
Row_Number() Over(Partition By referral_id Order By start_date,line) as rn
from hcclsc.referral_Bed_Day a
) A
Inner Join (
Select
a.referral_id,
max(rn) as vn
From (
Select
referral_id,
line,
bed_day_type_id,
start_date,
end_date,
Row_Number() Over(Partition by referral_id Order By start_date, line) as rn
From HCCLSC.referral_Bed_Day
) a
Group by referral_id
) B
On A.referral_ID = B.referral_id and a.rn = b.vn
推荐阅读
- javascript - 数组中所有值作为 div 的文本出现的次数
- java - 如何让2个动画连续运行
- vba - 如何解决错误 483:“对象不支持此属性或方法”
- r - 您可以从 (HTML) RMarkdown 文档发送电子邮件吗?
- r - 是否有比 flextable 更快的方法将表格添加到 ggplot 对象?
- python - ImportError:找不到 DLL“msvcp140.dll 或 msvcp140_1.dll”
- vue.js - 找不到模块:错误:无法解析“postcss-loader”vue 2.5.2 webpack 3.12.0
- android - Android + ESP32 通过蓝牙 (BLE) 发送数据
- r - 从 glmnet 的 tidymodel 实现中获取拟合值
- mongodb - 排序和过滤双嵌套 mongo 数组