
May 8th, 2003, 09:51 PM
|
|
Junior Member
|
|
Join Date: May 2003
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
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
|