MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old April 5th, 2004, 06:58 PM
djdevshed djdevshed is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 1 djdevshed User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Using Aggregate values in a update statment

I am trying to update a master table which has the following:
customer_no
fname,
lname,
FiscalYear,
attendance,
attribute1
..
Attribute25

I have at this point inserted all customers 3 times, each one having a fiscalyear = 2003, 2004, 2005

I am now trying to update the various attributes one by one with update statements like:

update lt_table
set attendance = isnull(SUM(CASE when sp.sp_act = 39
THEN 1 ELSE 0 END), 0)

from lt_table x, t_special_activity sp
where x.customer_no *= sp.customer_no
and x.fiscalYear = dbo.lf_fy(sp.sp_act_dt)
group by
x.customer_no, dbo.lf_fy(sp.sp_act_dt)
having dbo.lf_fy(sp.sp_act_dt) >= 2003

SQL server returns error:
An aggregate may not appear in the set list of an UPDATE statement.

Any ideas or paradigm shifts for this are much appreciated, I know there must be a much better approach to this project.

Thanks,

dj

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Using Aggregate values in a update statment


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway