Hi Folks,
I have the following query:
SELECT First([APCGeneral].[PATID]) AS [PATID Field],
First([APCGeneral].[SPELLNO]) AS [SPELLNO Field],
First([APCGeneral].[CONSEPNO]) AS [CONSEPNO Field],
First([APCGeneral].[STARTDT]) AS [STARTDT Field],
Count([APCGeneral].[PATID]) AS NumberOfDups
FROM APCGeneral
GROUP BY [APCGeneral].[PATID], [APCGeneral].[SPELLNO],
[APCGeneral].[CONSEPNO], [APCGeneral].[STARTDT]
HAVING (((Count([APCGeneral].[PATID]))>1) AND
((Count([APCGeneral].[STARTDT]))>1));
This gives a result as follows:
PATID SPELLNO CONSEPNO STARTDT NUMBEROFDUPS
(2135 ROWS)
What I actually want is as follows:
DATETIMEY PATID SPELLNO CONSEPNO STARTDT
(4395 ROWS)
i.e. a complete record for each duplicate
Where DATETIMEY is another column in the record that does not contain duplicate information (as IS the case over the other 4 columns). I need the records ordered by PATID and DATETIMEY and need to retain the record in each set of duplicates with the highest value for DATETIMEY.
Any and all help appreciated.
PompeyJon
I have the following query:
SELECT First([APCGeneral].[PATID]) AS [PATID Field],
First([APCGeneral].[SPELLNO]) AS [SPELLNO Field],
First([APCGeneral].[CONSEPNO]) AS [CONSEPNO Field],
First([APCGeneral].[STARTDT]) AS [STARTDT Field],
Count([APCGeneral].[PATID]) AS NumberOfDups
FROM APCGeneral
GROUP BY [APCGeneral].[PATID], [APCGeneral].[SPELLNO],
[APCGeneral].[CONSEPNO], [APCGeneral].[STARTDT]
HAVING (((Count([APCGeneral].[PATID]))>1) AND
((Count([APCGeneral].[STARTDT]))>1));
This gives a result as follows:
PATID SPELLNO CONSEPNO STARTDT NUMBEROFDUPS
(2135 ROWS)
What I actually want is as follows:
DATETIMEY PATID SPELLNO CONSEPNO STARTDT
(4395 ROWS)
i.e. a complete record for each duplicate
Where DATETIMEY is another column in the record that does not contain duplicate information (as IS the case over the other 4 columns). I need the records ordered by PATID and DATETIMEY and need to retain the record in each set of duplicates with the highest value for DATETIMEY.
Any and all help appreciated.
PompeyJon