SQL 输入中的Union问题

563
0

注册真麻烦 初学数据Lv2

发表于2022-1-20 12:59

楼主
请教专家,两个SQL查询Union在SQL输入组件中要怎么写?

(select s.* from ( select *, row_number() over (partition by ALOT_NUMBER order by COMPONENT_PART_ID ) as group_idx  
    from plating_test_04 where MACH_ID='PDF-01') s
where s.group_idx = 1) union (select *, row_number() over (partition by ALOT_NUMBER order by COMPONENT_PART_ID ) as group_idx  
    from plating_test_04 where MACH_ID='PDF-01')

系统报错:Caused by: com.esen.jdbc.pool.impl.mssql.MssqlPooledSQLException: Incorrect syntax near the keyword 'UNION'.

在调试时,我注意到:
整句的SQL语句:  (select s.* from ( select *, row_number() over (partition by ALOT_NUMBER order by COMPONENT_PART_ID ) as group_idx from plating_test_04 WHERE MACH_ID='PDF-01') s where s.group_idx = 1)

两端加上括号会报错:Caused by: com.esen.jdbc.pool.impl.mssql.MssqlPooledSQLException: Incorrect syntax near ')'.
去了括号就可以运行。Union与这个问题有关系吗?

感谢,在线等!

最近看过此主题的会员

iluna

张建

AngelinaBai

@bert

gly

dora232

mylawn

隔壁同学

admin

minmind

zhuxx

zhangxiaohua

0个回答

只看楼主

登录后可回答问题,请登录注册

快速回复 返回顶部 返回列表

小时

全天响应

分钟

快速处理问题

工程师强势助力

明星产品
解决方案
联系合作

渠道咨询电话:137-0120-6790

技术支持QQ:400-0011-866(工作日9:00-18:00)

产品建议邮箱yixin@esensoft.com

关注我们

扫TA学习更多干货

一对一专家交流

版权所有© 2006-2024 北京亿信华辰软件有限责任公司 京ICP备07017321号 京公网安备11010802016281号