Search Postgresql Archives

Re: ARRAY_AGG(DISTINCT a ORDER BY b) Error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"David Johnston" <polobo@xxxxxxxxx> 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 "accountnumber" and yet different
"amount" values.  Which of those amounts should be used as the sort key
for the aggregated row?

			regards, tom lane

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux