Re: Seamless replacement to MySQL's GROUP_CONCAT function...

From: "immersive(dot)excel(at)gmail(dot)com" <immersive(dot)excel(at)gmail(dot)com>
To: Richard Broersma <richard(dot)broersma(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, x3v0-pgsql(at)yahoo(dot)com, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>, David Fetter <david(at)fetter(dot)org>
Subject: Re: Seamless replacement to MySQL's GROUP_CONCAT function...
Date: 2013-08-05 18:06:12
Message-ID: 51FFE994.8050701@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
I believe his VARIADIC might cover the optional delimiter use, but
he suggests using an array aggregation function instead -which does
not return a string list, so you would still have to rework the
original queries.<br>
<br>
Now you could write a GROUP_CONCAT aggregate that uses a final
function to convert the array to a string list -but correct me if
I'm wrong, I believe the way I am concatenating as I go uses less
resources (an array of, say, 5000 elements versus a string...)<br>
<br>
But while I am testing use of the ANYELEMENT, I will see if VARIADIC
can simplify things a tad more...<br>
<br>
========================<br>
On 08/05/2013 01:15 PM, Richard Broersma wrote:
<blockquote
cite="mid:CABvLTWEZyie9+zZZ9+xJNgaPsNLOL=OfOn2KROSrbryyQY2QEg(at)mail(dot)gmail(dot)com"
type="cite">
<meta http-equiv="Context-Type" content="text/html;
charset=ISO-8859-1">
<div>
<div>For posterity that finalized function could be posted here:<br>
<br>
<a moz-do-not-send="true"
href="http://okbob.blogspot.com/2009/08/mysql-functions-for-postgresql.html">http://okbob.blogspot.com/2009/08/mysql-functions-for-postgresql.html</a>&nbsp;
<br>
<br>
</div>
There's already a GROUP_CONCAT, listed there, but I guess this
one was lacking in some way.<br>
</div>
<div><br>
<br>
<div>On Mon, Aug 5, 2013 at 10:04 AM, Alvaro Herrera <span>&lt;<a
moz-do-not-send="true"
href="mailto:alvherre(at)2ndquadrant(dot)com">alvherre(at)2ndquadrant(dot)com</a>&gt;</span>
wrote:<br>
<blockquote><a moz-do-not-send="true"
href="mailto:immersive(dot)excel(at)gmail(dot)com">immersive(dot)excel(at)gmail(dot)com</a>
escribi&oacute;:<br>
<div><br>
&gt; &nbsp; &nbsp; Note: I found some close-but-no cigar aggregates
shared online, but<br>
&gt; &nbsp; &nbsp; they would not accept integer arguments, nor
would they handle the<br>
&gt; &nbsp; &nbsp; optionally furnished delimiter. People would
suggesting casting the<br>
&gt; &nbsp; &nbsp; argument to the pseudo-GROUP_CONCAT. Again:
Rewrite perhaps hundreds<br>
</div>
&gt; &nbsp; &nbsp; of queries?&lt;br&gt;<br>
<br>
I don't think you need all the variations; you should be
able to make<br>
them all work with a single set of functions, taking
ANYELEMENT instead<br>
of text/int8/int4 etc.<br>
<span> <br>
<br>
--<br>
&Aacute;lvaro Herrera &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a moz-do-not-send="true"
href="http://www.2ndQuadrant.com/">http://www.2ndQuadrant.com/</a><br>
PostgreSQL Development, 24x7 Support, Training &amp;
Services<br>
<br>
<br>
--<br>
Sent via pgsql-general mailing list (<a
moz-do-not-send="true"
href="mailto:pgsql-general(at)postgresql(dot)org">pgsql-general(at)postgresql(dot)org</a>)<br>
To make changes to your subscription:<br>
<a moz-do-not-send="true"
href="http://www.postgresql.org/mailpref/pgsql-general">http://www.postgresql.org/mailpref/pgsql-general</a><br>
</span></blockquote>
</div>
<br>
<br>
<br>
-- <br>
Regards,<br>
Richard Broersma Jr.
</div>
</blockquote>
</body>
</html>

Attachment Content-Type Size
unknown_filename text/html 3.8 KB

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Stephen Brearley 2013-08-05 19:40:51 Re: Re: Postgres 9.2.4 for Windows (Vista) Dell Vostro 400, re-installation failure PLEASE CAN SOMEONE HELP!! (nearly fixed)
Previous Message immersive.excel@gmail.com 2013-08-05 17:55:59 Re: Seamless replacement to MySQL's GROUP_CONCAT function...