Home » RDBMS Server » Server Administration » SQL Help
SQL Help [message #370567] Thu, 23 December 1999 15:07 Go to next message
marcus
Messages: 9
Registered: July 1999
Junior Member
I am trying to select the most recent date using sql. I have several patients that have several appointment dates, but I only want to see the most recent. Anyone got any advice. I know it's probably easy, but for whatever reason I have no clue. Thanks.
Re: SQL Help [message #370569 is a reply to message #370567] Thu, 23 December 1999 20:49 Go to previous messageGo to next message
Paul
Messages: 164
Registered: April 1999
Senior Member
Marcus,
If all you want is to return 2 columns, a name and a date, you can
SELECT patient_name, MAX(appointment_date)
FROM your_table
GROUP BY patient_name;

If you need to return more columns than this (for example, if patient names are stored in FNAME and LNAME columns), you can use something like this:

SELECT fname, lname, appointment_date
from your_table t1
WHERE date = ( SELECT MAX(appointment_date)
FROM your_table t2
WHERE t2.fname = t1.fname
AND t2.lname = t1.lname );

Hope this helps,
Paul
Re: SQL Help [message #370572 is a reply to message #370567] Mon, 27 December 1999 01:40 Go to previous message
atul limaye
Messages: 1
Registered: December 1999
Junior Member
i want answer's of frequently asked queries using sql.
Previous Topic: How can index on the remote database be used ?
Next Topic: Problem in running Oracle server in MTS
Goto Forum:
  


Current Time: Thu Mar 28 05:00:34 CDT 2024