Re: [GENERAL] Issue with json_agg() and ordering

Поиск
Список
Период
Сортировка
От Bob Jones
Тема Re: [GENERAL] Issue with json_agg() and ordering
Дата
Msg-id CA+HuS5FZoqYvBLG7eX2W65fX5fJD8q9eerWzz0N_KOrZy_RuFA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [GENERAL] Issue with json_agg() and ordering  (Merlin Moncure <mmoncure@gmail.com>)
Список pgsql-general
>>
>> I guess that the order by should be in the aggregation.
>>
>> SELECT json_agg(a.* ORDER BY a.last_name, a.last_year DESC)
>> FROM my_table a;
>
> yes.  however, you would say, json_agg(a... not 'a.*').  The .*
> notation only works in certain contexts, and is transformed at parse
> time to, a.col1, a.col2, a.col3...  which would not work inside an
> aggregation function which can only handle a single column or record.
>
> merlin


Awesome ! Thanks Charles for the answer, and Merlin for the
tweaking/additional insight.


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

Предыдущее
От: "Peter J. Holzer"
Дата:
Сообщение: Re: [GENERAL] pglogical bidirectional replication of sequences
Следующее
От: Ken Tanzer
Дата:
Сообщение: [GENERAL] Fields re-ordered on JOIN with * and USING