I’m trying to get the average number of days between when a user closes a ticket to when they open their “next” ticket.
A sample of my MySQL table is below. You will notice that Mike has created 3 tickets, 9 days apart (July1-July 10) and 5 days (July 10-July 15) apart, average is 7 days. I can’t seem to figure out how to look for the last resolved date, anybody have any ideas?
This is what I have so far:
SELECT
Name,
Created,
Resolved,
avg(datediff("Last Ticket Resolved", created) AS last_tket_open
FROM
MyTable
WHERE
Name='Mike'
Name Created Resolved
---- ------- --------
Mike July 1 July 1
Jill July 2 July 3
Mike July 10 July 10
Harry July 11 July 11
Mike July 15 July 15
SQLFiddle Demo