Re: Cannot make delete duplicates query work
- From: David Vollmer <DavidVollmer@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 24 May 2006 10:04:02 -0700
Jeff,
Thank you for your quick reply. Can I use the query I did that found the
distinct records and append those records to the new table? Of course I would
need the other fields of data that are not now contained in that query.
Which of the duplicates is the one that is appended to the new table is not
important as I have a separate table with the other account numbers tied to
the customer numbers.
The other information in the duplicate records is not necessary for my
purposes.
David
"Jeff Boyce" wrote:
David.
Another approach might be to create a new (empty) table pattered after your
"customer" table, with a unique index set on the fields that contain
"duplicate" information.
Then you could create an append query, from your existing table to this new
table. Because of the unique index on the new table, "duplicates" in the
existing table will not be written.
Of course, if the data contained in the non-unique fields is different, how
would you decide which of the duplicate records holds the correct additional
data?
Before doing any of this, backup!
Regards
Jeff Boyce
Microsoft Office/Access MVP
"David Vollmer" <DavidVollmer@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E5ACCE7F-C811-4107-AD9D-646FEEB48B35@xxxxxxxxxxxxxxxx
I have a table with over 100,000 records. Only 26,740 are unique, meaning
that their customer number and customer name are the same. The reason they
are duplicated is that many have multiple account numbers. I have copied
all
of the customer numbers and all of the account numbers and put them in a
separate table along with an autonumber key field.
Now I need to delete every duplicated customer and then make the customer
number field a key field that will relate to the account number table. I
have
tried to follow the "Find, eliminate, or hide duplicate records in Access"
training method but to no avail.
The SQL of the "Distinct records" query is:
SELECT tblPrivateClientPortfolios.[Rlof Cust Num],
tblPrivateClientPortfolios.[M Name Full],
First(tblPrivateClientPortfolios.CustID) AS FirstOfCustID
FROM tblPrivateClientPortfolios
GROUP BY tblPrivateClientPortfolios.[Rlof Cust Num],
tblPrivateClientPortfolios.[M Name Full]
ORDER BY tblPrivateClientPortfolios.[M Name Full];
The SQL of the "Delete query" is:
DELETE tblPrivateClientPortfolios.*, distinct.[Rlof Cust Num],
distinct.FirstOfCustID
FROM tblPrivateClientPortfolios INNER JOIN [qryCustomers-DistinctRecords]
AS
[distinct] ON tblPrivateClientPortfolios.[Rlof Cust Num] = distinct.[Rlof
Cust Num]
WHERE (((distinct.[Rlof Cust Num])=[distinct].[Rlof Cust Num]) AND
((distinct.FirstOfCustID)<>[distinct].[FirstOfCustID]));
I have tried variation of the above but as written when I preview the
records that will be deleted I get no records as a result. I should be
getting around 75,000 records that will be deleted.
What am I doing wrong?
Thank you,
David Vollmer
- References:
- Re: Cannot make delete duplicates query work
- From: Jeff Boyce
- Re: Cannot make delete duplicates query work
- Prev by Date: Re: outer Join and NULL values...?!?!!!
- Next by Date: Re: using global self-relation in query?
- Previous by thread: Re: Cannot make delete duplicates query work
- Next by thread: Re: Cannot make delete duplicates query work
- Index(es):
Relevant Pages
|