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

Поиск
Список
Период
Сортировка
От hubert depesz lubaczewski
Тема Re: How to find not unique rows in a table?
Дата
Msg-id 20081008121546.GA31190@depesz.com
обсуждение исходный текст
Ответ на Re: How to find not unique rows in a table?  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Список pgsql-general
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@depesz.com / aim:depeszhdl / skype:depesz_hdl / gg:6749007

В списке pgsql-general по дате отправления:

Предыдущее
От: Michelle Konzack
Дата:
Сообщение: Re: how to use pam-pgsql
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Stats collector eats my CPU