"First" function returning garbage - even after sorting previous q

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I'm running a database with some medical information in it where I need to
identify the first malignant diagnoses for each patient. I used a query to
filter the data, leaving only entries that are listed as malignant. In those
queries I ordered the data by patient number and then date of procedure.

When I run a third query, grouping by patient number and using the "first"
function for the rest of the fields, the query does NOT return the first
fields. The previous query that it's working from has already sorted the
data, though! Why is it still picking arbitrary entries? How do I get around
this?

Thanks for any help. I hope I explained it alright.
 
mrselfdestruct said:
Hi,

I'm running a database with some medical information in it where I need to
identify the first malignant diagnoses for each patient. I used a query to
filter the data, leaving only entries that are listed as malignant. In those
queries I ordered the data by patient number and then date of procedure.

When I run a third query, grouping by patient number and using the "first"
function for the rest of the fields, the query does NOT return the first
fields. The previous query that it's working from has already sorted the
data, though! Why is it still picking arbitrary entries? How do I get around
this?

Thanks for any help. I hope I explained it alright.

Don't use FRIST() or LAST(). In your case use Min(date_column) for the
first date and Max(date_column) for the last date.
 
Thanks, man. That's what I ended up doing. Still, I find that the first and
last functions need some serious reworking. Being that inconsistent just
doesn't make any sense.
 
Back
Top