views:

198

answers:

1

Hi! 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!

A: 

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
mcrute
Without the assumption, you'd do SELECT YEAR(date_column) my_year, MONTH(date_column) my_month, ... GROUP BY YEAR(date_column), MONTH(date_column)
ysth