Re: Eliminating Dup Records

From: Martyn Richard Jones <martyn1_at_ibm.net>
Date: 1996/07/19
Message-ID: <31F07AFC.68CB_at_ibm.net>#1/1


Martyn Jones wrote:
>
> In article <31EE6504.667F_at_CAMBER.COM>, M Rajeshwar <MR1154_at_CAMBER.COM> says:
> >
> >Since the primary key constraints were disabled, one of my tables now is
> >flooded with duplicate records. I had known a method of maintaing
> >unique records, deleting duplicate records, but not able to recall it.
> >
> >Can anyone help me out in this regard ?
> >
> >Thanks
> >
> >Raj
>
> It's a long time since I did thos one, but you may care
> to try the following (test it first).
> OOOOPS!
   DELETE FROM TABLE my_table
 WHERE primary_key =
(SELECT a.primary_key
  FROM my_Table a, my_Table b
  WHERE a.primary_key = b.primary_key
  AND b.row_id > a.row_id)

There, that's better.  

> Martyn Jones
> Iniciativa para Data Warehouse
> San Lorenzod de El Escorial
Received on Fri Jul 19 1996 - 00:00:00 CEST

Original text of this message