1

I need some help with a mysql query. I have a table with columns entryID, nodeID, latitude, longitude, and timestamp. I want to retrieve the most recent lat/lon entry for each nodeID, i.e. I want to retrieve exactly one entry (the most recent) per unique nodeID.

Zaffy
  • 16,801
  • 8
  • 50
  • 77
Gavman
  • 23
  • 2

1 Answers1

0

You can do this:

SELECT t1.*
FROM tablename AS t1
INNER JOIN
(
   SELECT nodeID, MAX(timestamp) AS Latesttimestamp
   FROM tablename
   GROUP BY nodeID
) AS t2 ON t1.timestamp = t2.Latesttimestamp AND t1.nodeID = t2.nodeID
Mahmoud Gamal
  • 78,257
  • 17
  • 139
  • 164