Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id D1D462E02CD for ; Sun, 3 Feb 2008 07:44:08 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 91380-06 for ; Sun, 3 Feb 2008 07:44:05 -0400 (AST) Received: from hs-out-2122.google.com (hs-out-0708.google.com [64.233.178.244]) by postgresql.org (Postfix) with ESMTP id B809B2E02B9 for ; Sun, 3 Feb 2008 07:44:05 -0400 (AST) Received: by hs-out-2122.google.com with SMTP id k27so1794827hsc.3 for ; Sun, 03 Feb 2008 03:44:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:mime-version:content-type:x-google-sender-auth; bh=PLTKEBjs1Milu5Y+Cj/AW65NeetWNxPDaiO9g4fD160=; b=NFOZSFqFIqQ97yktQURwBElHS9RSuCyPv+1UG1FoHttlWKZlGyOzA8/PypMetb5bkk9OjcjKd9K+nl/2nNkCTANTwJcKBh6l47gS6y5fj+LWrgEw1UmKbKEGoM3t4HvRr09dAb9uTb5PYggGvMCzQHYnKjSdscgaukLJFVT2Tr8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:mime-version:content-type:x-google-sender-auth; b=rFs7pupQI/oG2+hEvtEBw0ds/eKUQN2tMbkYHt5kfPekNOJ8fwCcxFMFMlG7xr6HRRV2EUd9iGbPaxhtXxrUDmub4TcHTuxLoOXl843t1hUED3wBmvSc/w8+rHyHfOc5mMJU98+vFWMdVcI+Ce1dAvDPNhytG6uXEyu4s97NfcE= Received: by 10.150.196.5 with SMTP id t5mr2359915ybf.109.1202039044333; Sun, 03 Feb 2008 03:44:04 -0800 (PST) Received: by 10.151.26.19 with HTTP; Sun, 3 Feb 2008 03:44:04 -0800 (PST) Message-ID: Date: Sun, 3 Feb 2008 13:44:04 +0200 From: "sergey kapustin" To: pgsql-sql@postgresql.org Subject: Helper aggregate function MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_632_30241616.1202039044331" X-Google-Sender-Auth: 1fbfdf5ea99a4ea9 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/8 X-Sequence-Number: 30099 ------=_Part_632_30241616.1202039044331 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello! Can anyone tell me how i do this properly? create or replace function agg(varchar,varchar) returns void as $func$ select $1,count(*) from $2 group by $1 order by $1; $func$ Language SQL; Right now this wives me "ERROR: syntax error at or near "$2" at character 97 select $1,count(*) from $2 group by $1 order by $1;" Thank you! ------=_Part_632_30241616.1202039044331 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello!
Can anyone tell me how i do this properly?

create or replace function agg(varchar,varchar) returns void as $func$
        select $1,count(*) from $2 group by $1 order by $1;
$func$
Language SQL;

Right now this wives me "ERROR:  syntax error at or near "$2" at character 97
select $1,count(*) from $2 group by $1 order by $1;"

Thank you!



------=_Part_632_30241616.1202039044331--