Update inv i
SET i.total = ( select SUM(v.quantity * s.charges)
from invitem v
JOIN service s
ON s.idservice = v.idservice
WHERE v.datetime = i.datetime
AND v.invoiceid = i.id --- < I presume this link condition is missing also ...
)
WHERE i.datetime = @uniquekey
|