Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 835786339BA for ; Fri, 23 Apr 2010 07:45:32 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 27246-04-2 for ; Fri, 23 Apr 2010 10:45:07 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from kuber.nabble.com (kuber.nabble.com [216.139.236.158]) by mail.postgresql.org (Postfix) with ESMTP id 0956D6328E0 for ; Fri, 23 Apr 2010 07:45:09 -0300 (ADT) Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1O5GNg-0000XP-0S for pgsql-sql@postgresql.org; Fri, 23 Apr 2010 03:45:08 -0700 Message-ID: <28339793.post@talk.nabble.com> Date: Fri, 23 Apr 2010 03:45:08 -0700 (PDT) From: junaidmalik14 To: pgsql-sql@postgresql.org Subject: Re: count function alternative in postgres In-Reply-To: <20100406184714.GA3290@osiris.mauzo.dyndns.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: junaidmalik14@gmail.com References: <28126792.post@talk.nabble.com> <20100406184714.GA3290@osiris.mauzo.dyndns.org> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.14 tagged_above=-10 required=5 tests=AWL=0.770, BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201004/95 X-Sequence-Number: 34022 Thanks Ben. It works fine. Junaid. Ben Morrow-2 wrote: > > Quoth junaidmalik14@gmail.com (junaidmalik14): >> >> Is there any alternative of mysql function COUNT(DISTINCT expr,[expr...]) >> in >> postgres. We get error if we >> >> write count like this count(distinct profile.id, profile.name, >> profile.age) >> but it works well in mysql. > > Pg does support COUNT(DISTINCT ), but only for a single column. The best > I can come up with for multiple columns is > > select count(distinct profile.tuple) from > (select (id, name, age) as tuple from profile) > as profile; > > or alternatively > > select count(*) from > (select distinct (id, name, age) as tuple from profile) > as profile; > > Ben > > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql > > -- View this message in context: http://old.nabble.com/count-function-alternative-in-postgres-tp28126792p28339793.html Sent from the PostgreSQL - sql mailing list archive at Nabble.com.