I have 3 tables.
Patients, Orders, PatientWeights
PatientWeights has 3 fields. PatientID, WeighDate, Weight.
Orders has 3 fields. OrderID, PatientID, OrderDate.
Patients has 3 fields. PatientID, LastName, FirstName.
I want to create query that lists each Order. The trick is I need the weight of the patient that was the most recent weight for that patient listed in the PatientWeights table that is NOT greater than the OrderDate for that Order.
So the fields I need in the result are...
Orders.OrderID
Orders.OrderDate
Patients.PatientID
Patients.LastName
Patients.FirstName
PatientWeights.Weight (of the most recent weight prior to the OrderDate).
I know how to get the most recent weight for each patient, I just can seem to get the most recent weight that is not greater than the order date for each patient/order. Any suggestions?
Patients, Orders, PatientWeights
PatientWeights has 3 fields. PatientID, WeighDate, Weight.
Orders has 3 fields. OrderID, PatientID, OrderDate.
Patients has 3 fields. PatientID, LastName, FirstName.
I want to create query that lists each Order. The trick is I need the weight of the patient that was the most recent weight for that patient listed in the PatientWeights table that is NOT greater than the OrderDate for that Order.
So the fields I need in the result are...
Orders.OrderID
Orders.OrderDate
Patients.PatientID
Patients.LastName
Patients.FirstName
PatientWeights.Weight (of the most recent weight prior to the OrderDate).
I know how to get the most recent weight for each patient, I just can seem to get the most recent weight that is not greater than the order date for each patient/order. Any suggestions?