0

I have 5000 records for 200 patients weight records in the past 10 years.

00001   134.5 11/9/2009
00001   123.34 9/02/2009
00002   123.45 11/5/2009
00002   127.89 11/5/2007
00003   ......

I want query show

00001 134.5  11/9/2009
00002 123.45 11/5/2009

Each patient has the latest weight record. Any query can make it happen?

flag

1 Answer

1

Lets say your fields are named patientid, weight, date. Here is the query you can try:

select patientid, weight, date
from tablename
where date = (select max(date) from tablename as t 
where t.patientid = tablename.patientid)
link|flag

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.