-Original Message-
From: Tom Lane [mailto:t...@sss.pgh.pa.us]
Sent: Wednesday, August 31, 2011 7:10 PM
To: David Johnston
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] ARRAY_AGG(DISTINCT a ORDER BY b) Error
"David Johnston" writes:
> "in an aggregate with
On 31 August 2011 23:54, David Johnston wrote:
> "in an aggregate with DISTINCT, ORDER BY expressions must appear in argument
> list"
>
> Why?
>
> If I add the fields of the ORDER BY expression to the DISTINCT clause I can
> no longer use DISTINCT since the ORDER BY values are not unique. Nor do I
"David Johnston" writes:
> "in an aggregate with DISTINCT, ORDER BY expressions must appear in argument
> list"
> Why?
Because the results are ill-defined otherwise. In your example,
> ... ARRAY_AGG(DISTINCT accountnumber ORDER BY amount DESC) ...
there may be many rows with the same "a