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

From Scott Bailey
Subject Re: count function alternative in postgres
Date
Msg-id 4BB790AB.6000904@comcast.net
Whole thread Raw
In response to count function alternative in postgres  (junaid malik <junaidmalik14@gmail.com>)
Responses Re: count function alternative in postgres
List pgsql-general
junaid malik 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
>
> Thanks
>

I already answered your question on dbforums.com. But in Postgres you
can do:

SELECT COUNT( DISTINCT row(col1, col2, col3) ) FROM foo
or
SELECT COUNT( DISTINCT (col1, col2, col3) ) FROM foo

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: ERROR: cache lookup failed for relation X
Next
From: Scott Bailey
Date:
Subject: Re: any built-in function to get time in seconds?