MySQL average times

Calculating average times in SQL

MySQL average times

I was trying to calculate average time in MySQL. I had a “time” field. After fooling around I came up with:

SELECT SEC_TO_TIME( SUM(TIME_TO_SEC(actual_arrival))/COUNT(actual_arrival)) FROM arrival_times;

It actually is pretty fast too.