我有一个表包含日期,距离和TimeForDistance ...
有没有办法使用MySQL语句计算每月平均速度?
真的很感激任何帮助!
答案 0 :(得分:0)
我认为你正在寻找这样的东西:
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