foxtrot123
Registered User.
- Local time
- Today, 03:26
- Joined
- Feb 18, 2010
- Messages
- 57
I have a table that tracks changes made to patients' hearing aids (DeviceID) over the course of several doctor visits. In the example below, the patient was given two hearing aids (DeviceID 4 & 5 were "Added") at Visit 1. On Visit 2, DeviceID 5 was repositioned, on Visit 3 it was recalibrated, and on Visit 4 it was removed.
I am trying to write a query that will select only devices that have not been "Removed." In this case, the query should return only one record (the first one, for DeviceID 4).
Any suggestions? I obviously can't just use the criteria "<> Removed" because this would still include the records for Device 5 when it was Added, Repositioned, and Recalibrated.
Code:
PatientID VisitID DeviceID Procedure
----------------------------------------
1 1 4 Added
1 1 5 Added
----------------------------------------
1 2 5 Repositioned
----------------------------------------
1 3 5 Recalibrated
----------------------------------------
1 4 5 Removed
Any suggestions? I obviously can't just use the criteria "<> Removed" because this would still include the records for Device 5 when it was Added, Repositioned, and Recalibrated.