From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | Thom Brown <thom(at)linux(dot)com>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: string_agg delimiter having no effect with order by |
Date: | 2010-08-04 15:29:39 |
Message-ID: | 19470.1280935779@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-hackers |
Robert Haas <robertmhaas(at)gmail(dot)com> writes:
> 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.
Done:
+ <para>
+ When dealing with multiple-argument aggregate functions, note that the
+ <literal>ORDER BY</> clause goes after all the aggregate arguments.
+ For example, this:
+ <programlisting>
+ SELECT string_agg(a, ',' ORDER BY a) FROM table;
+ </programlisting>
+ not this:
+ <programlisting>
+ SELECT string_agg(a ORDER BY a, ',') FROM table; -- not what you want
+ </programlisting>
+ The latter syntax will be accepted, but <literal>','</> will be
+ treated as a (useless) sort key.
+ </para>
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2010-08-04 16:37:23 | Re: In 8.2, shutdown wrongly caused automatic restart |
Previous Message | Shine | 2010-08-04 14:53:02 | BUG #5598: Compatibility modes |
From | Date | Subject | |
---|---|---|---|
Next Message | Joshua Tolley | 2010-08-04 16:17:35 | Re: GROUPING SETS revisited |
Previous Message | Simon Riggs | 2010-08-04 15:26:30 | Re: merge command - GSoC progress |