I would like to get the average time of solution time for tickets
from state 'billet ouvert' to state 'résolu'.
The queries I tried:
Query 1:
SELECT
title AS 'Etat', ticket_id, user_id,
AVG(TIMESTAMPDIFF(HOUR,
helpdesk_followup.date having title in ('billet ouvert'),
helpdesk_followup.date having title in ('résolu'))
) AS 'moyenne'
FROM helpdesk_followup
GROUP BY user_id;
Query 2:
SELECT
title AS 'Etat', ticket_id, user_id,
AVG(TIMESTAMPDIFF(HOUR,
helpdesk_followup.date as date1,
helpdesk_followup.date as date2)
) AS 'moyenne'
FROM helpdesk_followup
WHERE date1 having title IN 'résolu'
AND date2 having title IN 'billet ouvert'
GROUP BY user_id;
But these queries doesn't get the result I need. How can I add condition to a timestampdiff?
The first column is the starting event and the second column is the end event. I have done the average in minutes. This SQL works off the title which you may wish to tweak to something more distinct
I have left out the user_id from the query as I'm unsure if you wish to break it down using that field.
Hopefully its a start for you to amend into what you need
EDIT: Here is the test data I used for the query