I am given this database, and I need to select out a table, which contains following columns: idticket, note_subject, customer_name, agent_name, note_state, note_priority, note_delivery. I have to loop trough all the tickets, find the newest note to each one a fetch corresponding information across the database. Please, help, I am desperate! Thanks for any advice!

Code:
(http://oi40.tinypic.com/2hghbo0.jpg)