Det er overflødigt at sige, at jeg hader at arbejde med MySQL :
SELECT AVG(delay_answer)
FROM (SELECT MIN(delay_answer) AS delay_answer
FROM (SELECT M1.ref, client, admin, TIMESTAMPDIFF(SECOND, date_original, date) AS delay_answer
FROM messages M1
INNER JOIN (SELECT ref, MIN(date) AS date_original
FROM messages
GROUP BY ref) M2
ON M1.ref = M2.ref AND date > date_original
WHERE admin <> 0 AND client = 0) x
GROUP BY ref) y;
Dette returnerer den gennemsnitlige tid (i sekunder), som det tog for en administrator at besvare en besked (oprettet af enhver, ikke nødvendigvis en klient, men dette kan nemt ændres).