Basic MySQL autogeneration statistics

I have a table containing Dates, Distances and Times ForDistance ...

Is there a way to calculate the average monthly rate using MySQL expressions?

Any help would be really appreciated!

0


source to share


1 answer


I think you are 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

      

0


source







All Articles