X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8684432B116 for ; Fri, 22 Oct 2004 08:49:39 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 24694-08 for ; Fri, 22 Oct 2004 07:49:30 +0000 (GMT) Received: from fzkmail2.fzk.de (fzkmail2.fzk.de [141.52.27.52]) by svr1.postgresql.org (Postfix) with SMTP id C242C32B10D for ; Fri, 22 Oct 2004 08:49:34 +0100 (BST) Received: FROM resy5.fzk.de BY fzkmail2.fzk.de ; Fri Oct 22 09:49:30 2004 +0200 Received: from rodos.fzk.de (resy6.fzk.de [141.52.68.10]) by resy5.fzk.de (8.12.7/8.12.7/SuSE Linux 0.6) with ESMTP id i9M7nTtj015658; Fri, 22 Oct 2004 09:49:29 +0200 Message-ID: <4178BB88.D7175ADC@rodos.fzk.de> Date: Fri, 22 Oct 2004 09:49:28 +0200 From: Christoph Haller X-Mailer: Mozilla 4.77 [en] (X11; U; HP-UX B.10.20 9000/780) X-Accept-Language: en MIME-Version: 1.0 To: Kent Anderson , pgsql-sql@postgresql.org Subject: Re: Finding duplicated values References: Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS - amavis-milter (http://www.amavis.org/) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/159 X-Sequence-Number: 19262 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.I was trying to use the code below but it > returned no rows.SELECT hmhmkey, wmwmkey > FROM exceptions > EXCEPT > SELECT hmhmkey, wmwmkey FROM exceptions;Any suggestions?Kent > Anderson You might want to search the [SQL] archive on the following topics for more inspiration: selecting duplicate records Delete 1 Record of 2 Duplicate Records Regards, Christoph