Re: ARRAY_AGG(DISTINCT a ORDER BY b) Error

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: ARRAY_AGG(DISTINCT a ORDER BY b) Error
Дата
Msg-id 6119.1314832223@sss.pgh.pa.us
обсуждение исходный текст
Ответ на ARRAY_AGG(DISTINCT a ORDER BY b) Error  ("David Johnston" <polobo@yahoo.com>)
Ответы Re: ARRAY_AGG(DISTINCT a ORDER BY b) Error  ("David Johnston" <polobo@yahoo.com>)
Список pgsql-general
"David Johnston" <polobo@yahoo.com> 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

В списке pgsql-general по дате отправления:

Предыдущее
От: "David Johnston"
Дата:
Сообщение: ARRAY_AGG(DISTINCT a ORDER BY b) Error
Следующее
От: Thom Brown
Дата:
Сообщение: Re: ARRAY_AGG(DISTINCT a ORDER BY b) Error