Re: DISTINCT in STRING_AGG

Поиск
Список
Период
Сортировка
От Geoff Winkless
Тема Re: DISTINCT in STRING_AGG
Дата
Msg-id CAEzk6fcQa9d7yS+NTh+X09PJZyoJ54kfzVORp8oZ4BCMTCkG-g@mail.gmail.com
обсуждение исходный текст
Ответ на Re: DISTINCT in STRING_AGG  ("Sterpu Victor" <victor@caido.ro>)
Ответы Re: DISTINCT in STRING_AGG  (Geoff Winkless <pgsqladmin@geoff.dj>)
Re: DISTINCT in STRING_AGG  ("Sterpu Victor" <victor@caido.ro>)
Список pgsql-general
On 29 November 2015 at 18:59, Sterpu Victor <victor@caido.ro> wrote:
I can't skip the ordering.
I'm sure aqjs3 is the one that produces the duplication.
I guess subqueries are the only option, like this:

​Well you could look at the intarray ​extension and a combination of array_agg, uniq() and string_to_array:


but that's probably sledgehammer:nut time.

Not sure why you need to order the values you're getting back by something other than the values themselves - is there a reason you wouldn't want the "children"​ set to be ordered numerically? You can still order the outer query by whatever you like, or you can order the aggregate by the values themselves, it's just the DISTINCT inside the aggregate query requires that an internal ORDER includes the ordering term in the result.

​Geoff​

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

Предыдущее
От: "Sterpu Victor"
Дата:
Сообщение: Re: DISTINCT in STRING_AGG
Следующее
От: Geoff Winkless
Дата:
Сообщение: Re: DISTINCT in STRING_AGG