SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Update issue
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

crownclit
Starting Member

16 Posts

Posted - 03/04/2013 :  23:42:09  Show Profile  Reply with Quote
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 expression

Without GroupBy statement runs but updates grand total for all agents instead per individual.

Thanx

CC

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 03/04/2013 :  23:48:42  Show Profile  Reply with Quote

UPDATE rc 
SET rc.RC11 = rc11.RCSUM
FROM #RC rc
INNER JOIN  (SELECT AgentId ,SUM(RC) AS RCSUM 
             FROM #RC11 
             GROUP BY AgentId) rc11
ON rc.AgentId = rc11.AgentId 


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

crownclit
Starting Member

16 Posts

Posted - 03/05/2013 :  16:44:18  Show Profile  Reply with Quote
thank you visakh16 works perfect now :-)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 03/06/2013 :  01:01:53  Show Profile  Reply with Quote
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000