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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with MIN function 1

Status
Not open for further replies.

georgia51390

Programmer
May 17, 2001
13
US
Hi there,
I have a table of patient IDs and appointment dates. Patients may be in the table a number of times with different appointment dates. I need to create a new table with each patient ID only once and their EARLIEST appointment date. Is that possible with the MIN function?
Thank you!
 

Yes. Just Select MIN(ApptDate) to get the earliest date in the table. Use group by on PatientID to get the earliest date per patient.

Select PatientID, MIN(ApptDate)
From table
Group By PatientID

NOTE: This works if the ApptDate field is datetime data type. If you've stored dates as text, it may not work without converting the date to datetime. Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time.
NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top