Hi!

We have a database that stores vehicle's gps position, date, time, vehicle identification, lat, long, speed, etc., every minute.

The following select pulls each vehicle position and info, but the problem is that returns the first record, and I need the last record (current position), based on date (datagps.Fecha) and time (datagps.Hora). This is the select:

SELECT configgps.Fichagps, datacar.Ficha, groups.Nombre, datagps.Hora, datagps.Fecha, datagps.Velocidad, datagps.Status, datagps.Calleune, datagps.Calletowo, datagps.Temp, datagps.Longitud, datagps.Latitud, datagps.Evento, datagps.Direccion, datagps.Provincia FROM asigvehiculos INNER JOIN datacar ON (asigvehiculos.Iddatacar = datacar.Id) INNER JOIN configgps ON (datacar.Configgps = configgps.Id) INNER JOIN clientdata ON (asigvehiculos.Idgroup = clientdata.group) INNER JOIN groups ON (clientdata.group = groups.Id) INNER JOIN datagps ON (configgps.Fichagps = datagps.Fichagps) Group by Fichagps;

I need same result Im getting, but instead of the older record I need the most recent
(LAST datagps.Fecha / datagps.Hora).


How can I accomplish this?

Thanks a lot!

do not store separate date and time
store a single unix timestamp or sql datetime (both of which can output date, time, or date and time

then just
select max(dategps.datetime)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.