Jump to content

MySQL Report


wildasIwanabe

Recommended Posts

Hi,

 

I've been playing around with some data in MySQL.  I can manage to enter the data with no problem but I'm a having a little problem trying to generate a report from the data.

 

Basically, the data contains 3 fields.  Date, distance ran and Time taken.  Whenever I go for a run, I enter my results into the mysql table.  I then have a script to get the best time for each distance ran.  That part works great, but the date that the best time was ran is wrong.  Please see my attachment for a better understanding.  I have several 5km runs, and my best time was in June, but it shows that it was in April.

 

This is the query I wrote in PHP...

$query = "SELECT MIN(time), distance, rundate FROM running group by distance";

 

Am I missing something from the query ???

 

thanks.

 

 

 

 

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

Something like this may get the results that you want:

select allRuns.* from(
select time, distence, date from location 
)allRuns join(
select min(time) as time, distence 
from running 
group by distance
) minDistence 
on      allRuns.time = minDistence.time 
	and allRuns.distence = minDistence.distence

Although I'm sure there is a better way, I just can't think of it right now.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.