两个选择上的 UNION 给出“SQL 错误:ORA-00907:缺少右括号”;
我正在尝试合并两个查询的结果。但我收到以下错误:
Error at Command Line:9 Column:81
Error report:
SQL Error: ORA-00907: missing right parenthesis
00907. 00000 - "missing right parenthesis"
这是我的查询:
SELECT application_id, clicks, datee, client_id FROM(
(select
APPL_CD AS application_id,
count(*) as clicks,
to_date((to_char(ACTN_TAKE_DATA_TM, 'dd-mm-yyyy')), 'dd-mm-yyyy') as datee,
ALRT_RSPNS_FROM_CLIENT_ID AS client_id
from ALRT_PLATFORM_ALRT_HSTRY
where ACTN_TAKE_CD is not null
group by to_char(ACTN_TAKE_DATA_TM, 'dd-mm-yyyy'), APPL_CD, ALRT_RSPNS_FROM_CLIENT_ID order by datee)
UNION ALL
(select
APPL_CD AS application_id,
count(*) as clicks,
to_date((to_char(ACTN_TAKE_DATA_TM, 'dd-mm-yyyy')), 'dd-mm-yyyy') as datee,
ALRT_RSPNS_FROM_CLIENT_ID AS client_id
from ALRT_PLATFORM_ALRT
where ACTN_TAKE_CD is not null
group by to_char(ACTN_TAKE_DATA_TM, 'dd-mm-yyyy'), APPL_CD, ALRT_RSPNS_FROM_CLIENT_ID order by datee )
)
I'm trying to UNION the results of two queries. But I'm getting the following error:
Error at Command Line:9 Column:81
Error report:
SQL Error: ORA-00907: missing right parenthesis
00907. 00000 - "missing right parenthesis"
Here's my query:
SELECT application_id, clicks, datee, client_id FROM(
(select
APPL_CD AS application_id,
count(*) as clicks,
to_date((to_char(ACTN_TAKE_DATA_TM, 'dd-mm-yyyy')), 'dd-mm-yyyy') as datee,
ALRT_RSPNS_FROM_CLIENT_ID AS client_id
from ALRT_PLATFORM_ALRT_HSTRY
where ACTN_TAKE_CD is not null
group by to_char(ACTN_TAKE_DATA_TM, 'dd-mm-yyyy'), APPL_CD, ALRT_RSPNS_FROM_CLIENT_ID order by datee)
UNION ALL
(select
APPL_CD AS application_id,
count(*) as clicks,
to_date((to_char(ACTN_TAKE_DATA_TM, 'dd-mm-yyyy')), 'dd-mm-yyyy') as datee,
ALRT_RSPNS_FROM_CLIENT_ID AS client_id
from ALRT_PLATFORM_ALRT
where ACTN_TAKE_CD is not null
group by to_char(ACTN_TAKE_DATA_TM, 'dd-mm-yyyy'), APPL_CD, ALRT_RSPNS_FROM_CLIENT_ID order by datee )
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从嵌套查询中删除
ORDER BY
:Remove the
ORDER BY
from the nested queries: