473,406 Members | 2,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

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
2 8412
deric
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
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

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

Similar topics

2
by: carmen | last post by:
I'm using the code below to display the results in rows with the column header as hyperlinks that will sort the rows by colum heading. Is there a way to have the results sorted (as default) in...
4
by: R. Santiago | last post by:
I have a table cc_rd_user_questions with the following columns: NUM NUMBER (25) DEFAULT 1 NOT NULL, COMPANY_ID NUMBER (15) NOT NULL, PROJ_ID NUMBER (15) NOT NULL, SEQ ...
1
by: Milo Woodward | last post by:
I have some columns of data in SQL server that are of NVARCHAR(420) format but they are dates. The dates are in DD/MM/YY format. I want to be able to convert them to our accounting system format...
6
by: DC | last post by:
Is there a way to use a column alias in an another calculation within the same query? Since I am using some long and complex logic to compute total1 and total2, I don't want to repeat the same...
8
by: pb648174 | last post by:
I have a single update statement that updates the same column multiple times in the same update statement. Basically i have a column that looks like .1.2.3.4. which are id references that need to...
2
by: Joe | last post by:
Hi All, I am new to using the Access DB and I need some help if someone is able to give it to me. What I want to do is get the names of the columns of certain tables. Not the data in the table...
9
by: rhaazy | last post by:
Using MS SQL 2000 I have a stored procedure that processes an XML file generated from an Audit program. The XML looks somewhat like this: <ComputerScan> <scanheader>...
4
by: Yas | last post by:
Hello, I was wondering if anyone can help me figure something out. Is it possible to do a querey in MS SQL server and have the results returned so that each result in each row is preceeded by...
1
by: CreativeMind | last post by:
hi all , actually i am binding a datagrid with a dataview which has a datatable showing output like this.. propertyid viewname 1 fronside 1 lefttside 1 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.