Re: count function alternative in postgres - Mailing list pgsql-hackers

From Robert Haas
Subject Re: count function alternative in postgres
Date
Msg-id w2j603c8f071004050900veeee8606z9bb394b3781dd6a3@mail.gmail.com
Whole thread Raw
In response to count function alternative in postgres  (junaidmalik14 <junaidmalik14@gmail.com>)
Responses Re: count function alternative in postgres  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
List pgsql-hackers
On Sat, Apr 3, 2010 at 8:59 AM, junaidmalik14 <junaidmalik14@gmail.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


pgsql-hackers by date:

Previous
From: Hitoshi Harada
Date:
Subject: Re: make check hangs in alpha5
Next
From: Heikki Linnakangas
Date:
Subject: Re: Re: [COMMITTERS] pgsql: Check compulsory parameters in recovery.conf in standby_mode, per