Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group