Hi All
I have a problem with a query that I am trying to derive to see what patients are reattending in the emergency department
The query that I have covers 6 months of data 01/01/2010 to 30/06/2010. The following SQL definitely works when I join an attendances table onto itself again, but it continues to repeat the patient ID at a later stage if that patient reattends and then duplicates the reattendances . For example if one patient attended at 01/01/2010 14:09, 03/01/2010 18:07, 04/04/2010 12:09, 05/06/2010 14:10, then the query will return 03/01/2010 18:07, 04/04/2010 12:09, 05/06/2010 14:10 for the attendance that occured on 01/01/2010 but later on it will return 04/04/2010 12:09, 05/06/2010 14:10 for the attendance 03/01/2010 etc
SELECT [Attendances fin].Patient_ID, [Attendances fin].ARRIVAL_DATETIME, [Attendances fin_1].ARRIVAL_DATETIME
FROM [Attendances fin] INNER JOIN [Attendances fin] AS [Attendances fin_1] ON [Attendances fin].Patient_ID = [Attendances fin_1].Patient_ID
WHERE ((([Attendances fin].ARRIVAL_DATETIME)<#6/30/2010# And ([Attendances fin].ARRIVAL_DATETIME)<>[Attendances fin_1].[ARRIVAL_DATETIME]))
ORDER BY [Attendances fin].ARRIVAL_DATETIME, [Attendances fin_1].ARRIVAL_DATETIME;
What I want to do is isolate the patients that have repeat attendances and to count the number of patients that have reattended more than 2 times. Anyone got some bright ideas?!
Regards
Frustrated!