A
Alex
I have the following find duplicates query, which returns the maximum value
in the SASNODemout.NPIEC field. What I need instead is the query to return
all BUT the maximum value. Min won't work because I could have 3 duplicate
records and I need two of the three returned; the two with the lowest NPIEC.
Can this be achieved? Thank you.
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;
in the SASNODemout.NPIEC field. What I need instead is the query to return
all BUT the maximum value. Min won't work because I could have 3 duplicate
records and I need two of the three returned; the two with the lowest NPIEC.
Can this be achieved? Thank you.
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;