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
Re: BUG #10972: string_agg function incorrectly concatenating varying delimiter Tom Lane <tgl@sss.pgh.pa.us>
Re: BUG #10972: string_agg function incorrectly concatenating varying delimiter Jeff Fischer <jeff@goaldriven.com>
Re: BUG #10972: string_agg function incorrectly concatenating varying delimiter Pavel Stehule <pavel.stehule@gmail.com>
Re: BUG #10972: string_agg function incorrectly concatenating varying delimiter Jeff Fischer <jeff@goaldriven.com>
Re: BUG #10972: string_agg function incorrectly concatenating varying delimiter Marti Raudsepp <marti@juffo.org>
On Wed, Jul 16, 2014 at 3:16 AM,   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
Дата:
От: Simon Riggs
Дата:
Сообщение: syntax error WITH ORDINALITY
FAQ