| From: | Robert Haas <robertmhaas(at)gmail(dot)com> | 
|---|---|
| To: | Thom Brown <thom(at)linux(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:04:49 | 
| Message-ID: | AANLkTincegXwDRwOM+gkgUeq7DwK_1SqCqp9yLhMmx20@mail.gmail.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-bugs pgsql-hackers | 
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.
-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Fujii Masao | 2010-08-04 13:13:17 | In 8.2, shutdown wrongly caused automatic restart | 
| Previous Message | Thom Brown | 2010-08-04 10:03:52 | Re: string_agg delimiter having no effect with order by | 
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Thom Brown | 2010-08-04 13:19:08 | Re: string_agg delimiter having no effect with order by | 
| Previous Message | Andres Freund | 2010-08-04 13:02:39 | Re: merge command - GSoC progress |