Re: SELECT DISTINCT and count(1)

From: nobs(at)nobswolf(dot)info (Emil Obermayr)
To: A B <gentosaker(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: SELECT DISTINCT and count(1)
Date: 2009-07-16 10:42:12
Message-ID: 20090716104212.GT30035@nobswolf.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Thu, Jul 16, 2009 at 11:57:56AM +0200, A B wrote:
>
> select distinct userid from usertable,<more tables> where <conditions>;
>
> and then count the rows in the result

make it a subselect and count in the outer select:

select count(*) as num from (select distinct...) dummy;

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message A B 2009-07-17 08:23:28 need some more select help
Previous Message A B 2009-07-16 10:16:32 Re: SELECT DISTINCT and count(1)