|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Using Aggregate values in a update statment |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|