Re: count function alternative in postgres

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: junaidmalik14 <junaidmalik14(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: count function alternative in postgres
Date: 2010-04-05 16:00:56
Message-ID: w2j603c8f071004050900veeee8606z9bb394b3781dd6a3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Apr 3, 2010 at 8:59 AM, junaidmalik14 <junaidmalik14(at)gmail(dot)com> wrote:
>
> 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.
>
> Reference url is given below
>
> http://dev.mysql.com/doc/refman/5.1/en/group-by-functions.html#function_count-distinct

You can do:

SELECT COUNT(*) FROM (SELECT DISTINCT profile.id, profile.name,
profile.age FROM ...) x;

...Robert

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2010-04-05 16:01:19 Re: Re: [COMMITTERS] pgsql: Check compulsory parameters in recovery.conf in standby_mode, per
Previous Message Hitoshi Harada 2010-04-05 15:49:15 Re: make check hangs in alpha5