Re: ERROR: cannot use aggregate function in RETURNING (in UPDATE) - Mailing list pgsql-novice

From Tom Lane
Subject Re: ERROR: cannot use aggregate function in RETURNING (in UPDATE)
Date
Msg-id 5939.1364163911@sss.pgh.pa.us
Whole thread Raw
In response to ERROR: cannot use aggregate function in RETURNING (in UPDATE)  (dinesh <dinesh@vssod.com>)
Responses Re: ERROR: cannot use aggregate function in RETURNING (in UPDATE)
List pgsql-novice
dinesh <dinesh@vssod.com> writes:
> I get an error saying cannot use aggregate function in RETURNING.
> Is this a bug or a feature?

Well, it's not a bug.  RETURNING is defined as returning one row per
row inserted/updated/deleted, so aggregates are nonsensical there.

In recent versions you could put the UPDATE RETURNING inside a WITH,
and then do the aggregation in a SELECT over that.

            regards, tom lane


pgsql-novice by date:

Previous
From: dinesh
Date:
Subject: ERROR: cannot use aggregate function in RETURNING (in UPDATE)
Next
From: dinesh
Date:
Subject: Re: ERROR: cannot use aggregate function in RETURNING (in UPDATE)