Article ID: 90477 - View products that this article applies to.
This article was previously published under Q90477
In an UPDATE statement, an aggregate function cannot appear directly in the SET list. For example, an attempt to execute a query such as,
generates the following message in 4.2:
An aggregate may not appear in the set list of an UPDATE statement.
(Msg 157, Level 15, State 1).
When an aggregate appears in the SET list of an UPDATE statement as above, there exists an ambiguity as to whether the associated WHERE clause qualifies the rows to be updated or it qualifies the rows on which to apply the aggregate function. The correct way to do this is:
This is in accordance with ANSI Specification.
Article ID: 90477 - Last Review: February 14, 2005 - Revision: 3.3
Contact us for more help