Hi coolsti,
Thanks alot that's made things alot clearer. I realise that now I do need to GROUP BY the results by the name and email and from what you said about the time, it sounds like I should be combining the time and milliseconds before using the min() function. You can't find the minimum of two columns I take it?
This leaves me with the following query:
Which much to my frustration is giving me all the results again.
So, I've selected the columns I want to output, next I've created a temporary table T2 and selected the id, name, email and min() of time + milliseconds, then GROUPed the results by name and email, which means I should have unique name and email values. I've then created another temporary table T3 and JOINed the results from T2 based on the name and email columns.
However, it seems the GROUP BY has been ignored somehow, I'm now getting all results again and in my results mintime is not a column.
Sorry to be a pain, I still can't get this to work.
Thanks alot that's made things alot clearer. I realise that now I do need to GROUP BY the results by the name and email and from what you said about the time, it sounds like I should be combining the time and milliseconds before using the min() function. You can't find the minimum of two columns I take it?
This leaves me with the following query:
Code:
SELECT scores.id, scores.name, scores.email, scores.time, scores.milliseconds FROM scores INNER JOIN ( SELECT T2.id, T2.name, T2.email, min(T2.time + T2.milliseconds) AS mintime FROM scores T2 GROUP BY T2.name, T2.email ) T3 ON scores.name = T3.name AND scores.email = T3.email
So, I've selected the columns I want to output, next I've created a temporary table T2 and selected the id, name, email and min() of time + milliseconds, then GROUPed the results by name and email, which means I should have unique name and email values. I've then created another temporary table T3 and JOINed the results from T2 based on the name and email columns.
However, it seems the GROUP BY has been ignored somehow, I'm now getting all results again and in my results mintime is not a column.
Sorry to be a pain, I still can't get this to work.
Comment