Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find distinct records that are not distinct
Message
From
16/11/2007 20:50:58
 
 
To
16/11/2007 17:24:03
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01269536
Message ID:
01269602
Views:
10
>>>Huh? I know, its a strange subject line. Here's my problem. Through something of a snafu we have about 600 records in a table that are improper duplicates of other records. We want to remove them. This would be easy with select distinct EXCEPT that one field "sequence" was provided to create a unique sequence number for each record. So, they are all distinct because they all have different sequence numbers. I can get around this by selecting into a cursor, deleting the sequence numbers, and then selecting dist from the cursor. This gives me the truly distinct records albeit without the sequence numbers. Now I need to put the original sequence numbers back. Any ideas on how to do this?
>>
>>Which one MAX() or MIN() sequence number?
>
>Your question would only pertain to the records that had a duplicate twin. I don't think it matters. Probably the min().
SELECT keyvalue,COUNT(keyvalue) AS knt FROM mytable GROUP BY keyvalue HAVING knt > 1
This will show you the duplicates. You can them link the query back to the table and browse the cursor and table simultaneously to find all the records, or programmatically delete the records you don't want to keep.
Carsten M. Thode
Previous
Reply
Map
View

Click here to load this message in the networking platform