两个选择上的UNION给出’SQL错误:ORA-00907:缺少右括号’

前端之家收集整理的这篇文章主要介绍了两个选择上的UNION给出’SQL错误:ORA-00907:缺少右括号’前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试UNION两个查询的结果.但是我收到以下错误
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,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,ALRT_RSPNS_FROM_CLIENT_ID order by datee )
)

解决方法

从嵌套查询删除ORDER BY:
SELECT application_id,ALRT_RSPNS_FROM_CLIENT_ID) 
UNION ALL
(select 
    APPL_CD AS application_id,ALRT_RSPNS_FROM_CLIENT_ID )
)
原文链接:https://www.f2er.com/mssql/74996.html

猜你在找的MsSQL相关文章