L
LMB
Hi Everyone,
Access 2003. I am trying to get a query to show me only the records for
each patient that is the most recent based on the the
PtLocationStartDateAndTime field. Right now in my test database I have 2
patients who I show in 2 different rooms on different dates. I see all 4
records. I only want to see the record for the newest location. Here is
the sql but I use the query grid at this point.
SELECT DISTINCTROW tblPtLocation.PtLocID, tblAreaList.AreaName,
tblBedsList.BedNumber, tblPatients.PtLName, [PtLocRmNum] & " " & [BedID_fk]
AS [RM Bd], tblPtLocation.PtLocStDtTm, tblPtLocation.PtLocEnDtTm,
tblPtLocation.BedID_fk, tblPtLocation.PtLocRmNum
FROM tblPatients INNER JOIN (tblBedsList INNER JOIN (tblAreaList INNER JOIN
tblPtLocation ON tblAreaList.AreaID = tblPtLocation.AreaID_fk) ON
tblBedsList.BedID = tblPtLocation.BedID_fk) ON tblPatients.PtID =
tblPtLocation.PtID_fk
GROUP BY tblPtLocation.PtLocID, tblAreaList.AreaName, tblBedsList.BedNumber,
tblPatients.PtLName, [PtLocRmNum] & " " & [BedID_fk],
tblPtLocation.PtLocStDtTm, tblPtLocation.PtLocEnDtTm,
tblPtLocation.BedID_fk, tblPtLocation.PtLocRmNum;
Thanks,
Linda
Access 2003. I am trying to get a query to show me only the records for
each patient that is the most recent based on the the
PtLocationStartDateAndTime field. Right now in my test database I have 2
patients who I show in 2 different rooms on different dates. I see all 4
records. I only want to see the record for the newest location. Here is
the sql but I use the query grid at this point.
SELECT DISTINCTROW tblPtLocation.PtLocID, tblAreaList.AreaName,
tblBedsList.BedNumber, tblPatients.PtLName, [PtLocRmNum] & " " & [BedID_fk]
AS [RM Bd], tblPtLocation.PtLocStDtTm, tblPtLocation.PtLocEnDtTm,
tblPtLocation.BedID_fk, tblPtLocation.PtLocRmNum
FROM tblPatients INNER JOIN (tblBedsList INNER JOIN (tblAreaList INNER JOIN
tblPtLocation ON tblAreaList.AreaID = tblPtLocation.AreaID_fk) ON
tblBedsList.BedID = tblPtLocation.BedID_fk) ON tblPatients.PtID =
tblPtLocation.PtID_fk
GROUP BY tblPtLocation.PtLocID, tblAreaList.AreaName, tblBedsList.BedNumber,
tblPatients.PtLName, [PtLocRmNum] & " " & [BedID_fk],
tblPtLocation.PtLocStDtTm, tblPtLocation.PtLocEnDtTm,
tblPtLocation.BedID_fk, tblPtLocation.PtLocRmNum;
Thanks,
Linda