sbrooks
04-03-2002, 07:40 AM
I know this issue has been addressed several times on this board, but I believe I have a little more complicated scenario. I want to be able to delete records based on duplication of 4 fields, but on top of that I want it to query FieldX and only delete duplicates where FieldX is null. I've tried implementing the following SQL code which is a modified Find Duplicates Query, to no avail:
SELECT tblName.Field1, tblName.[Field2], tblName.[Field3], tblName.[FieldX] FROM tblName WHERE (((tblName.Field1) In (SELECT [Field1] FROM [tblName] As Tmp GROUP BY [Field1],[Field2],[Field3] HAVING Count([tblName].[Field1])>1 And [Field2Name] = [tblName].[Field2] And [Field3Name] = [tblName].[Field3]))) AND (((tblName.FieldX) Is Null));
The problem is, while this will do away with dupes that are NULL in FieldX, it doesn't help with dupes that are BOTH null; I DO want at least one of them. Anyone have any further suggestions, I'm at my wit's end?
TIA
S. Brooks
SELECT tblName.Field1, tblName.[Field2], tblName.[Field3], tblName.[FieldX] FROM tblName WHERE (((tblName.Field1) In (SELECT [Field1] FROM [tblName] As Tmp GROUP BY [Field1],[Field2],[Field3] HAVING Count([tblName].[Field1])>1 And [Field2Name] = [tblName].[Field2] And [Field3Name] = [tblName].[Field3]))) AND (((tblName.FieldX) Is Null));
The problem is, while this will do away with dupes that are NULL in FieldX, it doesn't help with dupes that are BOTH null; I DO want at least one of them. Anyone have any further suggestions, I'm at my wit's end?
TIA
S. Brooks