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

From: dinesh <dinesh(at)vssod(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: ERROR: cannot use aggregate function in RETURNING (in UPDATE)
Date: 2013-03-25 08:20:28
Message-ID: 008d01ce2931$92e26550$b8a72ff0$@vssod.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Thanks Tom, that worked out great.

--

Regards

Dinesh

From: Tom Lane-2 [via PostgreSQL]
[mailto:ml-node+s1045698n5749485h20(at)n5(dot)nabble(dot)com]
Sent: Sunday, March 24, 2013 3:26 PM
To: dinesh
Subject: Re: ERROR: cannot use aggregate function in RETURNING (in UPDATE)

dinesh <[hidden email]> 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

--
Sent via pgsql-novice mailing list ([hidden email])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-novice

_____

If you reply to this email, your message will be added to the discussion
below:

http://postgresql.1045698.n5.nabble.com/ERROR-cannot-use-aggregate-function-
in-RETURNING-in-UPDATE-tp5749475p5749485.html

To unsubscribe from ERROR: cannot use aggregate function in RETURNING (in
UPDATE), click here
<http://postgresql.1045698.n5.nabble.com/template/NamlServlet.jtp?macro=unsu
bscribe_by_code&node=5749475&code=ZGluZXNoQHZzc29kLmNvbXw1NzQ5NDc1fDE2NjI2NT
kwODU=> .

<http://postgresql.1045698.n5.nabble.com/template/NamlServlet.jtp?macro=macr
o_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.B
asicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.templ
ate.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-insta
nt_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
NAML

--
View this message in context: http://postgresql.1045698.n5.nabble.com/ERROR-cannot-use-aggregate-function-in-RETURNING-in-UPDATE-tp5749475p5749505.html
Sent from the PostgreSQL - novice mailing list archive at Nabble.com.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message kobolds 2013-03-27 12:44:44 about .pgpass
Previous Message Tom Lane 2013-03-24 22:25:11 Re: ERROR: cannot use aggregate function in RETURNING (in UPDATE)