MarcieFess
Registered User.
- Local time
- Today, 08:01
- Joined
- Oct 25, 2012
- Messages
- 107
I have a problem that was caused by bad database architecture. I didn't know I could set a unique key that was a combination of 2 non-unique fields. I know that now.
Now I have a table with 1.3 million records. The true size of the table should be about one-tenth of that.
I believe the query can be run using 2 fields: ProductKey and StoreKey
I should have only 1 entry for each unique combination of ProductKey and StoreKey
Because I didn't have my attributes set properly when I imported files into the existing database, I have anywhere from 4 to 24 or more of each possible combination.
I have a query:
First of all, this is taking FOREVER to run.
Secondly, I deleted about 1,000 duplicates by hand. I don't want the unique records to get deleted.
What I want: retain one record for each unique ProductKey/StoreKey combination, and delete the rest of the duplicates.
I appreciate your help!
Marcie Fessler
Now I have a table with 1.3 million records. The true size of the table should be about one-tenth of that.
I believe the query can be run using 2 fields: ProductKey and StoreKey
I should have only 1 entry for each unique combination of ProductKey and StoreKey
Because I didn't have my attributes set properly when I imported files into the existing database, I have anywhere from 4 to 24 or more of each possible combination.
I have a query:
Code:
SELECT DISTINCT [Copy of tblStoreProducts3].ProductKey,
[Copy of tblStoreProducts3].StoreKey, [Copy of tblStoreProducts3].UPC
FROM [Copy of tblStoreProducts3]
WHERE ((([Copy of tblStoreProducts3].ProductKey) In (SELECT[ProductKey]
FROM
[Copy of tblStoreProducts3] As Tmp GROUP BY [ProductKey],
[StoreKey] HAVING Count(*)>1, And [StoreKey] =
[Copy of tblStoreProducts3.[StoreKey])))
ORDER BY [Copy of tblStoreProducts3].ProductKey, [Copy of tblStoreProducts3].StoreKey;
First of all, this is taking FOREVER to run.
Secondly, I deleted about 1,000 duplicates by hand. I don't want the unique records to get deleted.
What I want: retain one record for each unique ProductKey/StoreKey combination, and delete the rest of the duplicates.
I appreciate your help!
Marcie Fessler