Re: [HACKERS] Should the following work...? - Mailing list pgsql-hackers

From Clark Evans
Subject Re: [HACKERS] Should the following work...?
Date
Msg-id 37011B93.22617BEB@manhattanproject.com
Whole thread Raw
In response to Should the following work...?  (The Hermit Hacker <scrappy@hub.org>)
List pgsql-hackers
The Hermit Hacker wrote:
>
> select id
>   from clients
>  where id = ( select id
>                 from clients
>                where count(id) = 1 ) ;
>

Hmm.  If you are trying to identify 
duplicate id's then try :

select distinct id from client x
where 1 <  ( select count(id)      from client y    where y.id = x.id );


Ideally, this would be done as:

select a from   ( select a, count(a) cnt       from test   group by a ) where cnt < 2;

However, PostgreSQL dosn't support
dynamic views.  This, btw, is a 
very useful feature.

Hope this helps,

Clark


pgsql-hackers by date:

Previous
From: The Hermit Hacker
Date:
Subject: RE: [HACKERS] Should the following work...?
Next
From: Clark Evans
Date:
Subject: Re: [HACKERS] Should the following work...?