Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing Most Recent Record in a Query

Status
Not open for further replies.

camelk

Technical User
Mar 19, 2002
26
US
I have a table that stores patient progress reports. The Composite key is Patient Number (PtNo) and Date of Progress Report(DatePR). I have a query that accesses the records from the table. But....I want the query to access only the most recent record for each patient number. How do I write criteria that will let me do this.





 
Try this.

Select p.*
From PatientProgress As p
Where p.DatePR =
(Select Max(DatePR)
From PatientProgress
Where PtNo=p.PtNo) If you want to get the best answer for your question read faq183-874 and faq183-3179.
Terry L. Broadbent - DBA
SQL Server Page:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top