MySQL average times

Posted by Michael Palmer on Friday, September 28, 2007

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

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

It actually is pretty fast too.


comments powered by Disqus