del dup recs (fwd)
Posted in 1994
>
> Hello!
>
> Software: On-line 4.0
> OS: Interactive Unix 3.2
>
> Problem: Duplicate data in (supposedly) unique columns.
>
> Question: How do I remove the records with duplicate ssn columns if my data
> file has about 25,00 recs of which 8,000 ssn's are dups (according to a select
> count(distinct ssn), but data in the other columns may be different?
>
The problem is that - if it's truly a duplicate - then what is different?
answer - the rowid.
What I have done in this situation:
DEFINE p_rec, p_last_rec LIKE table.*,
p_rowid INTEGER
DECLARE c_dup CURSOR FOR
SELECT ROWID, *
FROM table
ORDER BY dup_field
FOREACH c_dup INTO p_ROWID, p_rec.*
IF p_rec.dup_field = p_last_rec.dup_field THEN
DELETE FROM table WHERE ROWID = p_rowid
# or LET msg = "DELETE FROM table WHERE ROWID = ", p_rowid
# DISPLAY msg
END IF
LET p_last_rec.* = p_rec.*
END FOREACH
You can fix up as you like.
cheers
j.
_____________________________________________________________________________
Jack Parker | Be frank and explicit with your
Hewlett Packard, BSMC Boise, Idaho, USA| lawyer.... It's his business to
jparker@hpbs3645.boi.hp.com | confuse the issue afterwards.
(208) 396-5388 (W) (208) 384-1623 (H) | - J. R. Solly
_____________________________________________________________________________
Any opinions expressed herein are my own and not those of my employers.
_____________________________________________________________________________