Hello,
I’m making a query “Max210” that should return SampleDate, InterpP210, and Patient ID from Table “tbl_Samples” for the most recent Sample Date when InterP210 is Negative. I’m getting duplicate patient Ids in query output for some reason. The db is attached.
Could someone please take a look.
Here is the query:
Thanks,
Mila
I’m making a query “Max210” that should return SampleDate, InterpP210, and Patient ID from Table “tbl_Samples” for the most recent Sample Date when InterP210 is Negative. I’m getting duplicate patient Ids in query output for some reason. The db is attached.
Could someone please take a look.
Here is the query:
Code:
SELECT T1.SampleDate, T1.InterpP210, T1.PatientID, (SELECT tbl_Samples.[ID] FROM tbl_Samples WHERE tbl_Samples.ID=T1.MAXOFID) AS MaxSample
FROM (SELECT tbl_Samples.SampleDate, tbl_Samples.InterpP210, tbl_Samples.PatientID, Max(tbl_Samples.ID) AS MaxOfID FROM tbl_Samples WHERE (((tbl_Samples.InterpP210)="Negative")) GROUP BY tbl_Samples.SampleDate, tbl_Samples.InterpP210, tbl_Samples.PatientID) AS T1;
Thanks,
Mila