Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
crownclit
Starting Member
20 Posts |
Posted - 2013-03-04 : 23:42:09
|
Having dramas with this simple update statement. Could someone please help me out.Sql:UPDATE #RC SET #RC.RC11 = (SELECT SUM(#RC11.RC) FROM #RC11 INNER JOIN #RC ON #RC.AgentId = #RC11.AgentId GROUP BY #RC11.AgentId)Error:Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expressionWithout GroupBy statement runs but updates grand total for all agents instead per individual.ThanxCC |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-03-04 : 23:48:42
|
[code]UPDATE rc SET rc.RC11 = rc11.RCSUMFROM #RC rcINNER JOIN (SELECT AgentId ,SUM(RC) AS RCSUM FROM #RC11 GROUP BY AgentId) rc11ON rc.AgentId = rc11.AgentId [/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
crownclit
Starting Member
20 Posts |
Posted - 2013-03-05 : 16:44:18
|
thank you visakh16 works perfect now :-) |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-03-06 : 01:01:53
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|