Re: BUG #10972: string_agg function incorrectly concatenating varying delimiter

Поиск
Список
Период
Сортировка
От Marti Raudsepp
Тема Re: BUG #10972: string_agg function incorrectly concatenating varying delimiter
Дата
Msg-id CABRT9RA=g1qs7rzy+J6bZG4Zt5QiBeKbfWUhKE78NH2MPbiWsw@mail.gmail.com
обсуждение исходный текст
Ответ на BUG #10972: string_agg function incorrectly concatenating varying delimiter  (jeff@goaldriven.com)
Список pgsql-bugs
On Wed, Jul 16, 2014 at 3:16 AM,  <jeff@goaldriven.com> wrote:
> Running the query below will show how the delimiter for the current row is
> actually the subsequent rows delimiter.  The sequence goes like this:
>
> TestBlah        1
> ITTest  2
> testfail        3
>
> Yet, the concatened output is this:
>
> "testblah 2 ITtest 3 testfail"

I think you're misunderstanding the point of the 2nd argument. It's
not there for just concatenating two arguments together, it's there to
be a delimiter between the strings being concatenated. Almost always
it should be a constant. For example if you want a result like
"TestBlah,ITTest,testfail", that would be much uglier to do without
the delimiter argument.

The behavior you want is available as simply:
  string_agg(Field1 || ' ' || RowIndex::text, ' ')

Regards,
Marti

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

Предыдущее
От: John R Pierce
Дата:
Сообщение: Re: BUG #11022: \copy report negative row number
Следующее
От: Simon Riggs
Дата:
Сообщение: syntax error WITH ORDINALITY