the name you are getting is random. you want:
create temporary table t1 as
select distance, min(speed) fastest_speed
from table1 group by distance;

select table1.name, table1.distance, table1.speed from
table1, t1
where table1.distance=t1.distance
and table1.speed=t1.fastest_speed;

P.S. I think it is not so great that mysql lets you have columns in the
select clause that are neither in the group by nor aggregated. It's
confusing.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Christian
Wix
Sent: Monday, April 23, 2001 6:02 PM
To: [EMAIL PROTECTED]
Subject: min () - sql troubles


Hi
SQL troubles:
I have a table containing 4 columns: "name" - string, "distance"-
double,
"speed" - time and "id" - AUTO_INCREMENT (Primery key)
I want a list of the fastest (speed) runner (name) of each distance and
the
speed.
I use:
select name, distance, min(speed) from table1 group by distance;
I get a list where the speed and the distyance are always correct but
the
name is not always.
Why is that?
What should I do?

Thanks,

// Chris - Copenhagen

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to