>Hi,
>
>I would like to create a SQL UPDATE that will update from a subquery. I have seen it here (on UT) but can't seem to find a message with an example. What I am trying to do is to have UPDATE that sets a value in a field based on the calculations done in another table in a sub-query. That is, I would have something like this:
>
>
>UPDATE TableA Set Field1 = SUM_TOT (select SUM( FLDA + FLDB) AS SUM_TOT FROM TableB group by
> TableB.FLDC)
>
>
>I am sure that above is not correct. But what is the correct syntax?
>
>TIA.
Update TableA Set Field1 = ST.Sum_TOT
FROM TableA INNER JOIN (select sum(FldA+FldB) as Sum_Tot from TableB group b y FldC) ST
ON TableA.FieldC = ST.FieldC
If it's not broken, fix it until it is.
My Blog