I want to write a mysql query that selects the final result in the figure below :

Thanks
Any solution, for this question.
I want to write a mysql query that selects the final result in the figure below :

Thanks
Any solution, for this question.
This may help you, Execute query as below:
SELECT *
FROM tickets
GROUP BY device_id
HAVING key_field = MAX(key_field)
ORDER BY device_id ASC
Will produce result as you expected:
| Key | ID device | ticket Number |
|---|---|---|
| 212 | 1 | 594 |
| 211 | 2 | 147 |