467,917 Members | 1,397 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,917 developers. It's quick & easy.

Sum up a column and then update a temp table with results

I am using SQL 2000. I want to sum up a column and then add that to a newly created table.

How do I do this in SQL Server ? Below is what I am getting the error on:

update #temptable
Set Aug_total = Sum(hist.amount)
Select sum(hist.amount)
from cust inner join hist on
cust.c_id = hist.c_id
where blah blah blah....

The error SQL returns is:
An Aggregate may not appear in the Set list of an Update statement.

How do I get sum totals to put into my temp table?
Oct 1 '08 #1
  • viewed: 7297
Share:
2 Replies
Is this what you mean?
Expand|Select|Wrap|Line Numbers
  1. update #temptable
  2. Set Aug_total = (
  3. Select sum(hist.amount)
  4. from cust inner join hist on 
  5. cust.c_id = hist.c_id
  6. where blah blah blah....)
Oct 2 '08 #2
An aggregate may not appear in the set list of an UPDATE
statement.

I also was struggling with this error

for some days finally i got the solution

Which all i put into my blog


http://sqlerrormessages.blogspot.com...ar-in-set.html
Aug 23 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by carmen | last post: by
4 posts views Thread by R. Santiago | last post: by
1 post views Thread by CreativeMind | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.