G
Guest
Hi
I want to eliminate duplicates according to the following criterias:
1. If a member has at least 1 row with Date of Shot between 9/1/03-3/31/04
and Accept Calls = Yes and Asked Question = Yes, we'll keep that row.
2. Otherwise, if they have at least 1 row with Date of Shot between
9/1/03-3/31/04 and Accept Calls = Yes, we'll keep that row.
3. Otherwise, if they have at least 1 row with Date of Shot between
9/1/03-3/31/04, we'll keep that row.
3. Otherwise, if they have at least 1 row with Accept Calls = Yes and Asked
Question = Yes, we'll keep that row.
4. Otherwise, if they have at least 1 row with Enroll, we'll keep that row.
5. Otherwise, it doesn't matter which row we keep.
After that I run my query ( it looked like It run) but at last I got the
following Access messge
*******************************************************************************
At most one record can be returned by this subquery. (Error 3354)
***A subquery of this kind cannot return more than one record. Revise the
SELECT statement of the subquery to request only one record.
What I am doing wrong? There was no a syntax error message. I have a feeling
that it is an aggregate function CONTRADICTS BETWEEN CONDITION but do not
know how to fix it :-(
DELETE *
FROM makepart1 AS M1
WHERE EXISTS
(SELECT *
FROM makepart1 As M2
WHERE ( M2.[member id] = M1.[member id]
AND M2.[Date of Shot if Known] <> m1.[Date of Shot if Known]
AND M2.[Date of Shot if Known] NOT BETWEEN 9/1/2003 AND 3/31/2004
OR ( M2.[Date of Shot if Known] IS NULL
OR M2.[Asked Question]<>"yes"
OR M2.[Accepts Calls]<>"Yes")
AND [Date of Shot if Known] =
(SELECT MAX([Date of Shot if Known])
FROM makepart1 as M3
WHERE M3.[MEMBER ID]=M1.[Member id]
GROUP BY M3.[member id], M3.[Date of Shot if Known] ,M3.[Accepts Calls]
HAVING COUNT(*) > 1)
AND [Date of Shot if Known] =
(SELECT MAX([Date of Shot if Known])
FROM makepart1 AS M4
WHERE M4.[member id] = M1.[member id]
AND [Date of Shot if Known] IS NOT NULL AND [Date of Shot if Known]
BETWEEN 9/1/2003 AND 3/31/2004 AND [Accepts Calls] ="yes"
GROUP BY M4.[member id],M4.[Date of Shot if Known],M4.[Accepts Calls]
HAVING COUNT(*) > 1)));
I want to eliminate duplicates according to the following criterias:
1. If a member has at least 1 row with Date of Shot between 9/1/03-3/31/04
and Accept Calls = Yes and Asked Question = Yes, we'll keep that row.
2. Otherwise, if they have at least 1 row with Date of Shot between
9/1/03-3/31/04 and Accept Calls = Yes, we'll keep that row.
3. Otherwise, if they have at least 1 row with Date of Shot between
9/1/03-3/31/04, we'll keep that row.
3. Otherwise, if they have at least 1 row with Accept Calls = Yes and Asked
Question = Yes, we'll keep that row.
4. Otherwise, if they have at least 1 row with Enroll, we'll keep that row.
5. Otherwise, it doesn't matter which row we keep.
After that I run my query ( it looked like It run) but at last I got the
following Access messge
*******************************************************************************
At most one record can be returned by this subquery. (Error 3354)
***A subquery of this kind cannot return more than one record. Revise the
SELECT statement of the subquery to request only one record.
What I am doing wrong? There was no a syntax error message. I have a feeling
that it is an aggregate function CONTRADICTS BETWEEN CONDITION but do not
know how to fix it :-(
DELETE *
FROM makepart1 AS M1
WHERE EXISTS
(SELECT *
FROM makepart1 As M2
WHERE ( M2.[member id] = M1.[member id]
AND M2.[Date of Shot if Known] <> m1.[Date of Shot if Known]
AND M2.[Date of Shot if Known] NOT BETWEEN 9/1/2003 AND 3/31/2004
OR ( M2.[Date of Shot if Known] IS NULL
OR M2.[Asked Question]<>"yes"
OR M2.[Accepts Calls]<>"Yes")
AND [Date of Shot if Known] =
(SELECT MAX([Date of Shot if Known])
FROM makepart1 as M3
WHERE M3.[MEMBER ID]=M1.[Member id]
GROUP BY M3.[member id], M3.[Date of Shot if Known] ,M3.[Accepts Calls]
HAVING COUNT(*) > 1)
AND [Date of Shot if Known] =
(SELECT MAX([Date of Shot if Known])
FROM makepart1 AS M4
WHERE M4.[member id] = M1.[member id]
AND [Date of Shot if Known] IS NOT NULL AND [Date of Shot if Known]
BETWEEN 9/1/2003 AND 3/31/2004 AND [Accepts Calls] ="yes"
GROUP BY M4.[member id],M4.[Date of Shot if Known],M4.[Accepts Calls]
HAVING COUNT(*) > 1)));