Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 024EB9FB635 for ; Thu, 21 Jun 2007 10:00:36 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 55419-02-4 for ; Thu, 21 Jun 2007 10:00:20 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.244]) by postgresql.org (Postfix) with ESMTP id 147A39FC16D for ; Thu, 21 Jun 2007 10:00:07 -0300 (ADT) Received: by an-out-0708.google.com with SMTP id c36so104357ana for ; Thu, 21 Jun 2007 06:00:06 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=CrR/YnKvRotVSLrhnuP/hgH29om7K8FgEWpWH41k+Hz4PsuUHJmfHheX/x2aIGaNrSiNv5S3rMeMu+k55jprifpo7U1fmUXcEa0sPztdIZvkYOVgShJ0WrGKmX9UYKb1qPL5KXP/XDXQctfYrbywq7VioeGwcviHJQ4V1yY1flY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=G0u9Qkr4oOBV5ZVF7n+q+5HyBHxi40qtFRTIeDspM6JqAz8VHGRFQ37kb2LuOXo7Qya5Lx+4GOAEQNt3H8OSXx3gtU9xHxIygW6wOjFHF7SVIzLywmA7zd6vRyUWc/s/G5IlPbp6/6OKz6Gz+4VX0FVXkU8f/TOX3Hoo4qFeyWQ= Received: by 10.100.111.16 with SMTP id j16mr1054542anc.1182430805541; Thu, 21 Jun 2007 06:00:05 -0700 (PDT) Received: by 10.100.144.11 with HTTP; Thu, 21 Jun 2007 06:00:05 -0700 (PDT) Message-ID: <1c23c8e70706210600he74293ci83bdbc557ee2dba8@mail.gmail.com> Date: Thu, 21 Jun 2007 16:00:05 +0300 From: "Loredana Curugiu" To: dev@archonet.com, andreas.kretschmer@schollglas.com, pgsql-novice@postgresql.org, pgsql-sql@postgresql.org Subject: Re: [SQL] Select last there dates In-Reply-To: <20070621095025.GG1405@a-kretschmer.de> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_136597_22613230.1182430805472" References: <1c23c8e70706210118h6b9490e3s11e2a6ba15cdff6c@mail.gmail.com> <20070621095025.GG1405@a-kretschmer.de> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200706/148 X-Sequence-Number: 19046 ------=_Part_136597_22613230.1182430805472 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Richard, Andreas, thank you very much for your solutions. I took a look on both solutions, but I choosed Andreas's solution because is shorter :) So Andreas, would you please give some more explanations on your solution? I didn't work with functions and aggregate till now. I don't understand how this comma_aggregate works. I can see that this function it is defined with two arguments, but the aggredate it is called with a single argument. And what is LANGUAGE sql IMMUTABLE STRICT ? CREATE FUNCTION comma_aggregate(text,text) RETURNS text AS ' > SELECT CASE WHEN $1 <> '''' THEN $1 || '', '' || $2 ELSE $2 END; ' > LANGUAGE sql IMMUTABLE STRICT; > > CREATE AGGREGATE comma (basetype=text, sfunc=comma_aggregate, stype=text, > initcond='' ); > > Best regards, Loredana ------=_Part_136597_22613230.1182430805472 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Richard, Andreas,

thank you very much for your solutions. I took a look on
both solutions, but I choosed Andreas's solution because
is shorter :)

So Andreas, would you please give some more explanations
on your solution? I didn't work with functions and aggregate till
now.

I don't understand how this comma_aggregate works. I can see that this
function it is defined with two arguments, but the aggredate it is called
with a single argument.

And what is LANGUAGE sql IMMUTABLE STRICT ?

CREATE FUNCTION comma_aggregate(text,text) RETURNS text AS '
SELECT CASE WHEN $1 <> '''' THEN $1 || '', '' || $2 ELSE $2 END; '
LANGUAGE sql IMMUTABLE STRICT;

CREATE AGGREGATE comma (basetype=text, sfunc=comma_aggregate, stype=text, initcond='' );



Best regards,
      Loredana
------=_Part_136597_22613230.1182430805472--