Hi to all:
I'm creation an small app to automatically create standings of the participants with their results of a competition.
I have two tables, one with the racers, and a second with their results. One racer can have several attempts and I only want one, their best result with the lowest time (think on a trial lap on a car race, racer one can have several attempts, but only want the one who had best results on a least time).
Well go for some DB stuff....
Table one is like this:
ID | Name | (Several columns describing participant)
Table two is like this:
HeatNo | Class | RacerID | Pos | Laps | Time | AvLap
Here is my select (beware, can be very ugly... I'm a spare time programmer 😃 )
$query = "SELECT ID,Name,RacerID,max(Laps) AS MaxLaps,min(Time) AS MinTme FROM Heats AS mangas LEFT JOIN Racers AS corredor IB mangas.RacerID = corredor.ID WHERE mangas.Class=\"E\" GROUP BY mangas.RacerID ORDER BY mangas.Vueltas DESC";
When I fire this query, the results are pretty weird, select the max value on the Laps column for one racer with their lowest time trial, but the data is on different rows, I need to select the row that has the highest value on Laps (Integer value) with the lowest value on Time (Float value - I need to retain fractions of second) not do a mix of their results... very puzzled. Any hints.
Thankyou in advance,
Alfonso