gpt4 book ai didi

sql - 两个选择上的 UNION 给出 'SQL Error: ORA-00907: missing right parenthesis'

转载 作者:行者123 更新时间:2023-12-03 04:43:18 25 4
gpt4 key购买 nike

我正在尝试合并两个查询的结果。但我收到以下错误:

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 )
)

最佳答案

从嵌套查询中删除 ORDER BY:

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)
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 )
)

关于sql - 两个选择上的 UNION 给出 'SQL Error: ORA-00907: missing right parenthesis',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2380733/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com