Assuming the fields in MySQL are TIMESTAMP or DATETIME, I would use two MySQL queries. One for specific tasks.
SELECT UNIX_TIMESTAMP(date_end) - UNIX_TIMESTAMP(date_start) AS seconds_to_complete_task
FROM a
One for the average result.
SELECT AVG(UNIX_TIMESTAMP(date_end)-UNIX_TIMESTAMP(date_start)) AS avg_seconds_to_complete_task
FROM a
source
share