2014-03-25 108 views
0
update DCC set DRR= 
    (select cast((CAST((SUM(EMI)/100) AS DECIMAL(2,2))+CAST((SUM([REPO ARREAR])/100) AS DECIMAL(2,2))) as decimal(2,2))/((TOTAL*35)/100)/0.01 
    from dcc 
    where (CURR_DATE BETWEEN '2014-01-01' and '2014-01-03') 
    GROUP BY TOTAL) 

这是我的查询我必须使用select查询将值存储在DRR中。使用select语句更新查询

Error: Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. The statement has been terminated.

+1

只有当查询返回多次相同的值时,“TOP 1”才是相关的。 –

+0

是的,公平的一点。 –

回答

0

更换线

select cast((CAST((SUM(EMI)/100) AS DECIMAL(2,2) 

select TOP 1 cast((CAST((SUM(EMI)/100) AS DECIMAL(2,2) 

当你更新行的列值,则需要提供一个标量值它。

+0

如果要更新每条记录,可以使用TOP 1更新所有行,并使用单个结果 – user2866575

+0

更新所有行,您可以使用键列上的连接执行更新查询。 –

+0

但我从一张表更新记录,所以我不能使用加入 – user2866575