To retrieve the time when a ticket was closed, is able to use the
"ticket_change" table like the following:
====
SELECT
t.id,
(
CASE t.status
WHEN 'closed'
THEN (
SELECT tc.time
FROM ticket_change AS tc
WHERE tc.ticket=
t.id AND field='status' AND newvalue='closed'
ORDER BY tc.time DESC LIMIT 1)
ELSE NULL
END
) AS closed_at
FROM ticket AS t
====
--
Jun Omae <
jun...@gmail.com> (大前 潤)