Update based on SUM columns
Posted on 2011-04-26
I have to update a column in a table based on sum of two column and the value of the sum if is >= third column then 1.
SET flag = 1
FROM tbl1 a
inner join tbl2 b
on a.ID = b.ID
AND a.LocID = b.LocID
WHERE SUM(b.Time1 + a.Time2) > = b.TimeLimit
This update gives me an error.
An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference.
Can anyone tell me how to resolve this error?