Re: count function alternative in postgres

From: Scott Bailey <artacus(at)comcast(dot)net>
To: junaid malik <junaidmalik14(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: count function alternative in postgres
Date: 2010-04-03 19:02:03
Message-ID: 4BB790AB.6000904@comcast.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Scott Bailey 2010-04-03 19:08:30 Re: any built-in function to get time in seconds?
Previous Message Andrus 2010-04-03 18:58:36 Re: How to implement word wrap