-- ## 13: closed tickets ## -- -- Closed tickets SELECT p.value AS __color__, id AS ticket, summary, component, milestone, t.type AS type, owner, status, time AS created, changetime AS _changetime, description AS _description, reporter AS _reporter, (select datetime(max(tc.time), 'unixepoch') from ticket_change tc where t.id = tc.ticket and field = 'status' and newvalue = 'closed') as closed FROM ticket t LEFT JOIN enum p ON p.name = t.priority AND p.type = 'priority' WHERE status='closed' ORDER BY closed DESC