My movies database stores runtimes as a TIME value formatted as HH:MM:SS. Here's how to calculate the average runtime.
Option 1: Output formatted in HH:MM:SS
SELECT SEC_TO_TIME(AVG(TIME_TO_SEC(runtime))) AS average_runtime FROM movies;
Output:
+-----------------+ | average_runtime | +-----------------+ | 01:44:12.7816 | +-----------------+
Option 2: Get the average number of minutes of each runtime.
SELECT ROUND(AVG(TIME_TO_SEC(runtime) / 60), 2) AS avg_minutes FROM movies;
Output:
+-------------+ | avg_minutes | +-------------+ | 104.21 | +-------------+