Query Stumper

K

kiwiz

How can I get the MAX LabDate for each MRN? I thought I could paste my huge
query into both ******** locations but no luck. Thanks for any help

SELECT * FROM (********) Q WHERE Q.LabDate = (SELECT MAX(LabDate) FROM
(********) Q2 WHERE Q2.MRN=Q.MRN



SELECT v.MRN, l.VisitID, l.LabDate, l.Albumin, l.Prealbumin, l.Triglyceride,
v.NST_Consulted_Date, v.NST_Date_Off_Service, v.InPatient_Outpatient

FROM tblVisits AS v INNER JOIN tblLabs AS l ON v.VisitID = l.VisitID

WHERE ((Not (l.Albumin) Is Null) AND (Not (v.NST_Consulted_Date) Is Null)
AND ((v.NST_Date_Off_Service) Is Null) AND
((v.InPatient_Outpatient)="inpatient")) OR ((Not (l.Prealbumin) Is Null) AND
(Not (v.NST_Consulted_Date) Is Null) AND ((v.NST_Date_Off_Service) Is Null)
AND ((v.InPatient_Outpatient)="inpatient")) OR ((Not (l.Triglyceride) Is
Null) AND (Not (v.NST_Consulted_Date) Is Null) AND ((v.NST_Date_Off_Service)
Is Null) AND ((v.InPatient_Outpatient)="inpatient"))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top