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

Re: Finding duplicated values

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Kent Anderson <kenta(at)ezyield(dot)com>
Cc: "Pgsql-Sql(at)Postgresql(dot) Org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Finding duplicated values
Date: 2004-10-21 20:09:50
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
On Thu, 21 Oct 2004, Kent Anderson wrote:

> I have a few tables that have duplicated values from an import from a
> different database. I have two keys I tried to set as primary and got an
> error
> ERROR:  could not create unique index
> DETAIL:  Table contains duplicated values.
> Is there some join I can use to compare the hmhmkey, wmwmkey pairs against
> the table to find duplicate values? Each pair key should be unique but the
> old database was less than normalized.

SELECT hmhmkey, wmwmkey
 FROM exceptions
 GROUP BY hmhmkey, wmwmkey
 HAVING count(*)>1;

In response to

pgsql-sql by date

Next:From: Dmitry TkachDate: 2004-10-21 22:44:23
Subject: Trouble with explicit joins
Previous:From: BricklenDate: 2004-10-21 19:20:42
Subject: Re: Finding duplicated values

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