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