I'm trying to create a query that finds rows w/ duplicate
"ContactKeys" then finds duplicate "AddressLine1s" out of the list of
duplicate "ContactKeys." (I tried subqueries but it was really slow)
I am trying to create a new table with only duplicate ContactKey rows,
and then I wanted to use that table to pick out the duplicate
AddressLine1 rows.
****** BEGIN CODE **************
SELECT *
INTO dupContactKeys
FROM Contacts
WHERE ContactKey IN (
SELECT ContactKey
FROM Contacts
GROUP BY ContactKey
HAVING COUNT(*) > 1)
SELECT *
FROM dupContactKeys
WHERE ContactKey IN (
SELECT AddressLine1, Zip
FROM Contacts
GROUP BY AddressLine1, Zip
HAVING COUNT(*) > 1)
ORDER BY ContactKey, TypeKey;
drop table dupContactKeys
****** END CODE *****************
This of course doesn't work. Please help, as I am going slightly mad!
Dusty