Re: ERROR: cannot use aggregate function in RETURNING (in UPDATE)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: dinesh <dinesh(at)vssod(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: ERROR: cannot use aggregate function in RETURNING (in UPDATE)
Date: 2013-03-24 22:25:11
Message-ID: 5939.1364163911@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

dinesh <dinesh(at)vssod(dot)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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message dinesh 2013-03-25 08:20:28 Re: ERROR: cannot use aggregate function in RETURNING (in UPDATE)
Previous Message dinesh 2013-03-24 20:15:41 ERROR: cannot use aggregate function in RETURNING (in UPDATE)