如何制定此查询
update forge..dimInteg2
set duplicates =
(select count(*) from (select idCover
from x90..dimCover
group by idCover
having count(*) > 1))
where dimTable = 'dimCover'
避免此错误
Line 6: Incorrect syntax near ')'.
与[SQL Server subquery syntax相似 但我似乎无法使用别名技巧。
我在SQL Server 2000上
答案 0 :(得分:3)
你错过了一个括号吗?
update forge..dimInteg2
set duplicates =
(select count(*) from (select idCover
from x90..dimCover
group by idCover
having count(*) > 1) ) --HERE
where dimTable = 'dimCover'
然后别名解决方案应该有效。
答案 1 :(得分:0)
尝试将字段dimTable添加到第二个选择语句:
update forge..dimInteg2
set duplicates =
(select count(*) from (select idCover --, dimTable HERE
from x90..dimCover
group by idCover
having count(*) > 1)
where dimTable = 'dimCover'
答案 2 :(得分:0)
您需要命名派生表。
更新forge..dimInteg2 设置重复= (从中选择count(dimCover.idCover)(选择idCover 来自x90..dimCover idCover分组 有计数(*)> 1)dimCover) 其中dimTable ='dimCover'