Question

I have a Table containig Dates, Distances, and TimeForDistance...

Is there any way to Calculate the average per month velocity using MySQL Statements?

Any Help would really be appreciated!

Was it helpful?

Solution

I think you're looking for something like this:

SELECT
    YEAR(my_date) as my_year, 
    MONTH(my_date) as my_month, 
    sum(Distance) / sum(TimeForDistance) AS velocity 
FROM your_table 
GROUP BY my_year, my_month
ORDER BY my_year, my_month
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top