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
  • 15,683
  • 8
  • 48
  • 76
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
  • 75,299
  • 16
  • 132
  • 159