-
注册真麻烦 初学数据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与这个问题有关系吗?
感谢,在线等!
(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与这个问题有关系吗?
感谢,在线等!