I have a table for vehicle data. Every minute new vehicle location is inserted into table. I want the latest id sorting by date inserted group by vehicle id.
- I have used the below sample query
SELECT id, vehicle_id, info_datetime
FROM vehicles_sensor_data
WHERE info_datetime IN (
SELECT MAX(info_datetime)
FROM vehicles_sensor_data
GROUP BY vehicle_id
);
But the output shows the first id row with latest datetime.
- Both images from single table.
- So, I need to get the latest id - 2454 with datetime marked in yellow row and group by vehicles.