Re: query for non-unique values?

Поиск
Список
Период
Сортировка
От Kevin Brannen
Тема Re: query for non-unique values?
Дата
Msg-id 3D8F9504.3020906@nurseamerica.net
обсуждение исходный текст
Ответ на query for non-unique values?  ("Andy Kriger" <akriger@greaterthanone.com>)
Список pgsql-general
Andy Kriger wrote:
> I have a file of legacy data that has duplicate entries in a column that I'd
> like to have a unique index on. How can I query to find the duplicates (so I
> can determine if they can be thrown out)?

If you have yet to learn about self joins, this is a great example of
where they are handy.  Assuming a table like:

create table abc
(
    id int not null, -- primary key
    name text,       -- duplicates are here
);

Try something like:

select b.*
from abc a, abc b
where a.id < b.id
   and a.name = b.name;

HTH,
Kevin


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

Предыдущее
От: pilsl@goldfisch.at
Дата:
Сообщение: Re: bug(?) : order by function limit x
Следующее
От: Elaine Lindelef
Дата:
Сообщение: Re: OID order = INSERT order?