maryjo2001
IS-IT--Management
I am trying to select the most recent room number based on the maximum row identifier.
Table1 contains these fields:
UID,Date,Room,PatientID
Data in Table1:
1,7/1/02,456B,Amy74
2,7/1/02,234C,Amy74
3,7/1/02,457D,Amy74
Data I would like to see based on query:
3,7/1/02,457D,Amy74
Code I wrote but did not give me what I wanted:
SELECT DISTINCT
Table1.PatientID, Table1.Date, Table1.Room, MAX(Table1.UID)
FROM Table1
GROUP BY
Table1.Date, Table1.Room, Table1.PatientID
ORDER BY
Table1.PatientID,Table1.Date ASC, Table1.UID DESC
any help would be greatly appreciated.
Table1 contains these fields:
UID,Date,Room,PatientID
Data in Table1:
1,7/1/02,456B,Amy74
2,7/1/02,234C,Amy74
3,7/1/02,457D,Amy74
Data I would like to see based on query:
3,7/1/02,457D,Amy74
Code I wrote but did not give me what I wanted:
SELECT DISTINCT
Table1.PatientID, Table1.Date, Table1.Room, MAX(Table1.UID)
FROM Table1
GROUP BY
Table1.Date, Table1.Room, Table1.PatientID
ORDER BY
Table1.PatientID,Table1.Date ASC, Table1.UID DESC
any help would be greatly appreciated.