From: | Thom Brown <thom(at)linux(dot)com> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | pgsql-bugs <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: string_agg delimiter having no effect with order by |
Date: | 2010-08-04 13:19:08 |
Message-ID: | AANLkTikLO_=4Xb2dTkOw3p+U_HDFx1QS3AhQVBEs_ZHw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-hackers |
On 4 August 2010 14:04, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Wed, Aug 4, 2010 at 6:03 AM, Thom Brown <thom(at)linux(dot)com> wrote:
>> Actually, this rings a bell. I think this may have been raised
>> before, something to do with the delimiter being accepted as one of
>> the order by values. If this isn't really a bug, could someone
>> mention it in the docs somewhere?
>
> Oh, yeah. I guess you need this:
>
> select thing, string_agg(stuff, ',' order by stuff) from agg_test
> group by thing;
>
> Rather than this:
>
> select thing, string_agg(stuff order by stuff, ',') from agg_test
> group by thing;
>
> It's all kinds of not obvious to me what the second one is supposed to
> mean, but I remember this was discussed before. Perhaps we need a
> <note> somewhere about multi-argument aggregates.
>
Yes, that works with the order clause. That's really weird! It looks
like part of the delimiter parameter, and that's undocumented, or at
least impossible to gleen from the documentation.
This should be clarified as it looks like having ORDER BY *or* a
delimiter is supported, but not both. It's horribly unintuitive!
This is one of the very few cases where MySQL's version actually makes
more sense.
Thom
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2010-08-04 13:24:22 | Re: string_agg delimiter having no effect with order by |
Previous Message | Fujii Masao | 2010-08-04 13:13:17 | In 8.2, shutdown wrongly caused automatic restart |
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2010-08-04 13:24:22 | Re: string_agg delimiter having no effect with order by |
Previous Message | Robert Haas | 2010-08-04 13:04:49 | Re: string_agg delimiter having no effect with order by |