Re: [GENERAL] Are multiple array_aggs going to be in the same order?

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: [GENERAL] Are multiple array_aggs going to be in the same order?
Дата
Msg-id CAHyXU0yMpkrvcOd7-9oN5fd_27WUeaF2K9ccMydo=WX5G66CRg@mail.gmail.com
обсуждение исходный текст
Ответ на [GENERAL] Are multiple array_aggs going to be in the same order?  (Guyren Howe <guyren@gmail.com>)
Ответы Re: [GENERAL] Are multiple array_aggs going to be in the same order?
Re: [GENERAL] Are multiple array_aggs going to be in the same order?
Список pgsql-general
On Sun, Apr 9, 2017 at 4:27 PM, Guyren Howe <guyren@gmail.com> wrote:
>
> If I do a SELECT with a GROUP_BY and multiple ARRAY_AGGs, will the ARRAY_AGGs be guaranteed to have entries in the
same(ie corresponding) order? 
>
> eg
>
> SELECT
> u.name,
> ARRAY_AGG(o.order_date) AS order_dates,
> ARRAY_AGG(o.order_total) AS order_totals
> FROM
> user u JOIN
> orders o USING (user_id)
> GROUP BY
> u.user_id


It is unsafe to rely on aggregation order unless specified -- you can
add ORDER BY to the aggregation clause.

merlin


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

Предыдущее
От: Tom DalPozzo
Дата:
Сообщение: Re: [GENERAL] WAL being written during SELECT * query
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [GENERAL] Are multiple array_aggs going to be in the same order?