0

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. enter image description here

enter image description here

  • Both images from single table.
  • So, I need to get the latest id - 2454 with datetime marked in yellow row and group by vehicles.
Alexey Usharovski
  • 1,404
  • 13
  • 31
Kamal Sanghavi
  • 175
  • 1
  • 12

0 Answers0