MySQL Forums
Forum List  »  Newbie

Re: GROUP BY, MIN() row ordering problems!
Posted by: Max Waterman
Date: January 28, 2008 01:04AM

My first attempts shows I don't know what to expect...the examples in your first post are probably for different data. This is what I'm trying :
SELECT *, MIN(r.time) FROM results AS r JOIN athletes AS a USING (athleteID) GROUP BY athleteID;
+-----------+----------+-------+----------+----------+------------+--------+------+---------+-------------+--------+-------------+------------+-----------+-----------+--------+------------+--------+-------------+
| athleteID | resultID | event | ageGroup | time     | distHeight | record | wind | placing | competition | in_out | venue       | date       | nameFirst | nameLast  | gender | DOB        | clubID | MIN(r.time) |
+-----------+----------+-------+----------+----------+------------+--------+------+---------+-------------+--------+-------------+------------+-----------+-----------+--------+------------+--------+-------------+
|       199 |       23 | 100m  | SM       | 00010.59 | 000000     |        | 0.9  | 2       | Battle      | Out    | North Shore | 2008-01-02 | Craig     | BEARDA    | M      | 1982-06-17 |    151 | 00010.59    | 
|       822 |       20 | 100m  | SM       | 00010.46 | 000000     |        | 1.7  | 3       | RESI        | Out    | Sydney      | 2008-01-02 | James     | DOLPHIN   | M      | 1983-06-17 |    151 | 00010.20    | 
|       825 |       22 | 100m  | SM       | 00010.58 | 000000     |        | 1.6  | 1       | Centre      | Out    | Dunedin     | 2008-01-02 | Chris     | DONALDSON | M      | 1975-05-26 |    151 | 00010.56    | 
|      3450 |       28 | 100m  | SM       | 00010.20 | 000000     |        | 1.3  | 1       | Test Meet   | Out    | Inglewood   | 2008-02-02 | Gavin     | LOVEGROVE | M      | 1967-10-21 |    151 | 00010.15    | 
+-----------+----------+-------+----------+----------+------------+--------+------+---------+-------------+--------+-------------+------------+-----------+-----------+--------+------------+--------+-------------+
Could you post the expected results for the dataset you provide?

Thanks.

Max.
PS '
' tags will print in constant width font...makes reading easier.

Options: Reply• Quote




Sorry, you can't reply to this topic. It has been closed.
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.