Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Delete record with dup pkey

Delete record with dup pkey

From: Mark Weghorst <weghorst_at_nilenet.com>
Date: 17 Aug 1998 20:03:51 GMT
Message-ID: <6ra2b7$7fp$1@news1.rmi.net>


I could really use someones help with a problem that I've got. I've got some data with duplicate primary keys(not currently enabled), and I need to delete one of them, but I want to delete the one with the most null columns. For example:

select * from sometable where pkey = '17109';

Pkey	Column1		Column2		Column3		Column4
=====	=======		=======		=======		=======
17109	source1		31728		10628		
17109	source2						10/6/96

In this instance I want to keep the first record and delete the second. After the duplicate pkeys are elimated I can alter the table and create the primary key and other constraints.

The big question is how on earth do I select the row with the most null fields for deletion given a primary key value. I've considered using the max() function to create 2 identical rows, but I'd really like to be able to just delete the one with the most nulls.

Thanks in advance.

-Mark Weghorst Received on Mon Aug 17 1998 - 15:03:51 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US