Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 8th, 2003, 09:51 PM
vmon vmon is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 1 vmon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question help with Update SQL statement

What am I doing wrong. I am getting the grand total in the update column. I want to sum of Amount_Collected by Id. When I run the Select on it's own I get a total by Id.

UPDATE ##AgencyPerf
SET ##AgencyPerf.PreviousCollected =
(SELECT SUM(dbo.tblCollections_Trans.Amount_Collected)
FROM ##AgencyPerf LEFT OUTER JOIN
dbo.tblCollections_Trans ON ##AgencyPerf.ID_Eclipse = dbo.tblCollections_Trans.ID_Eclipse
WHERE dbo.tblCollections_Trans.Date_Transact < CONVERT(DATETIME, '2002-05-05 00:00:00', 102)
and dbo.tblCollections_Trans.Id_Eclipse = ##AgencyPerf.Id_Eclipse
GROUP BY ##AgencyPerf.ID_Eclipse)
WHERE dbo.tblCollections_Trans.Id_Eclipse = ##AgencyPerf.Id_Eclipse

Thanks,
vmon

Reply With Quote
  #2  
Old May 10th, 2003, 11:04 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
It looks like you're trying to update values in a temp table from which you trying to read values from. At least that's what i think you're trying to do. Logically, i'm not sure how this is possible. You might want to use another temp table to hold the values you want to write into the ##AgencyPerf table.
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > help with Update SQL statement


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 5 hosted by Hostway
Stay green...Green IT