Skip site navigation (1) Skip section navigation (2)

Re: string_agg delimiter having no effect with order by

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 (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-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

In response to

Responses

pgsql-hackers by date

Next:From: Thom BrownDate: 2010-08-04 13:19:08
Subject: Re: string_agg delimiter having no effect with order by
Previous:From: Andres FreundDate: 2010-08-04 13:02:39
Subject: Re: merge command - GSoC progress

pgsql-bugs by date

Next:From: Fujii MasaoDate: 2010-08-04 13:13:17
Subject: In 8.2, shutdown wrongly caused automatic restart
Previous:From: Thom BrownDate: 2010-08-04 10:03:52
Subject: Re: string_agg delimiter having no effect with order by

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group