epoch report

select id, summary, ticket.time,
a.time as accepted_datetime,
c.time as closed_datetime,
c.author as Closer
from ticket
left join (
SELECT ticket, author, newvalue AS status, max(time) AS time
FROM ticket_change WHERE field = 'status' and status = 'accepted'
GROUP BY ticket, newvalue
) AS a on (a.ticket = ticket.id and a.status = "accepted")
left join (
SELECT ticket, author, newvalue AS status, max(time) AS time
FROM ticket_change WHERE field = 'status' and status = 'closed'
GROUP BY ticket, newvalue
) AS c on (c.ticket = ticket.id and c.status = "closed")