A
Alex
I have the following "find duplicates" query that returns the records with
the maximum value in the NPIEC field. What I need instead is for the query
to return the records with all BUT the maximum value. Min won't work because
I could have 3 records containing duplicates. If I have NPIEC values of 2, 4
& 5 in 3 duplicate records, I need the query to return the records with the
NPIEC values of 2 & 4. Can this be done? Thanks.
SELECT SASNoDemout.MODEL, SASNoDemout.PT, SASNoDemout.VERS,
Min(SASNoDemout.NPIEC) AS MinOfNPIEC, 1 AS NPIECHigh
FROM SASNoDemout
GROUP BY SASNoDemout.MODEL, SASNoDemout.PT, SASNoDemout.VERS, 1
HAVING (((SASNoDemout.MODEL) In (SELECT [MODEL] FROM [SASNoDemout] As Tmp
GROUP BY [MODEL],[PT],[VERS] HAVING Count(*)>1 And [PT] = [SASNoDemout].[PT]
And [VERS] = [SASNoDemout].[VERS])))
ORDER BY SASNoDemout.MODEL, SASNoDemout.PT, SASNoDemout.VERS;
the maximum value in the NPIEC field. What I need instead is for the query
to return the records with all BUT the maximum value. Min won't work because
I could have 3 records containing duplicates. If I have NPIEC values of 2, 4
& 5 in 3 duplicate records, I need the query to return the records with the
NPIEC values of 2 & 4. Can this be done? Thanks.
SELECT SASNoDemout.MODEL, SASNoDemout.PT, SASNoDemout.VERS,
Min(SASNoDemout.NPIEC) AS MinOfNPIEC, 1 AS NPIECHigh
FROM SASNoDemout
GROUP BY SASNoDemout.MODEL, SASNoDemout.PT, SASNoDemout.VERS, 1
HAVING (((SASNoDemout.MODEL) In (SELECT [MODEL] FROM [SASNoDemout] As Tmp
GROUP BY [MODEL],[PT],[VERS] HAVING Count(*)>1 And [PT] = [SASNoDemout].[PT]
And [VERS] = [SASNoDemout].[VERS])))
ORDER BY SASNoDemout.MODEL, SASNoDemout.PT, SASNoDemout.VERS;