Hello André,

If you want to find out whats the oldest ticket closed, run the following query:

SELECT tn, create_time, MIN( id ) 
FROM ticket
WHERE ticket_state_id
IN (

SELECT id
FROM ticket_state
WHERE type_id =3
)

You could count them replacing the first line for:

SELECT COUNT( tn ) 

And you could list them all replacing the first line for:

SELECT tn, create_time

And appending the following line at the end:

ORDER BY `ticket`.`create_time` ASC 

I hope it helps. Regards,

Leonardo Certuche