By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,574 Members | 1,968 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,574 IT Pros & Developers. It's quick & easy.

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

P: 31
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
Share this Question
Share on Google+
2 Replies

P: 92
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

P: 4
An aggregate may not appear in the set list of an UPDATE

I also was struggling with this error

for some days finally i got the solution

Which all i put into my blog
Aug 23 '09 #3

Post your reply

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