I have a table (still on MySQL 5.7) with lots of data. This table is written by some scripts. It works like a "checkin", where each agent is checking in in some period of time. It looks like below.
I'd like to pick the most fresh line per each agent. So in above example I'd like to get row 100 and 101.
I use following script, but it turns out only first two rows. I tried changing order by id or timestamp ASC/DESC.
SELECT * FROM (SELECT * FROM db_table ORDER BY timestamp ASC) as agnt GROUP BY agent
How to make it working?