>I need to find potentially duplicate records in my membership database. The search needs to do the following:
>Look at all records with a system assigned ssn (our system assigned numbers start with "000") and compare them to all other records to check for people with the same last name living in the same city. I have created a subset table containing only the records with system assigned ssns, but I am sort of scratching my head as to what to do next. The main table is unavailable to me for esclusive use... should I copy it in order to create additional indexes to search on? Is there a single SQL statement that would take care of this? Thanks in advance for any help.
I think I understand your question... If you want to simply find out if the membership table has any duplicate ssns you could sql-select that counts the occurences of each ssn, then search through that cursor to find any counts over 1.
Something like this...
select membership.ssn, cnt(membership.ssn) as dupnum;
from membership;
group by membership.ssn;
into cursor snncnts
select ssncnts.ssn, ssncnts.dupnum
from ssncts;
where ssncnts.dupnum > 1
If you are looking for names/city that may be duplicate with a different ssn then you could do something similar. I think this works...
select membership.name, membership.city, cnt(ssn) as dupcnt;
from membership;
group by membership.name + city;
into cursor memcnts
select *;
from memcnts;
where memcnts.dupcnt > 1
Or you could join the table to itself...
select membership.name;
from membership;
where membership.name = membership.name;
and membership.city = membership.city;
and membership.ssn <> membership.ssn;
I haven't tested any of these, but just off the top of my head these are a few solutions. I think I link the last one the best. I hope this was the question that you were asking.
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only