Search Postgresql Archives

Re: How to find not unique rows in a table?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 08, 2008 at 01:36:37PM +0200, A. Kretschmer wrote:
> test=*# select * from dup;
>  a | b
> ---+---
>  1 | 1
>  1 | 2
>  2 | 1
>  1 | 1
>  3 | 3
>  3 | 3
> (6 rows)
> 
> test=*# select * from dup where (ctid,a,b) not in (select distinct on (a,b) ctid,* from dup);
>  a | b
> ---+---
>  1 | 1
>  3 | 3
> (2 rows)

another approach:
select a,b from dup group by a,b having count(*) > 1;

depesz

-- 
Linkedin: http://www.linkedin.com/in/depesz  /  blog: http://www.depesz.com/
jid/gtalk: depesz@xxxxxxxxxx / aim:depeszhdl / skype:depesz_hdl / gg:6749007


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux