Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Update using an Aggregate statement??

Status
Not open for further replies.

btturner

Programmer
May 17, 2001
175
0
0
US
Can anyone tell me how to UPDATE a column w/ an aggregate value (sum) w/in an UPDATE statement?

I receive the error: "An aggregate may not appear in the set list of an UPDATE statement" in the follwoing code:

update TabAAA set A.col_777 = sum(A.Salary)
from TabAAA A TabBBB B,
where (A.col_1 = B.col_1)
and (A.col_2 = B.col_2)
 
update TabAAA set A.col_777 = (Select sum(B.Salary)
from TabBBB B
where (A.col_1 = B.col_1)
and (A.col_2 = B.col_2))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top