Sql Query:
SELECT ticket.tn, ticket.id,ticket_history.state_id,ticket_state.name, max(ticket_history.change_time) AS change_time
FROM ticket_history
LEFT JOIN ticket ON (ticket.id = ticket_history.ticket_id)
LEFT JOIN ticket_state ON (ticket_state.id = ticket_history.state_id)
LEFT JOIN ticket_state_type ON (ticket_state_type.id = ticket_state.type_id)
WHERE ticket_history.history_type_id = 27 AND
ticket_state_type.name !="closed"
GROUP BY ticket.tn;
At the moment it just groups the records and only gets the max date and not the row associated with the max date
Thank you & Regards,
Kalyana chakravarthy M .P,
Sr software Engineer