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.
Asked
Active
Viewed 77 times
1 Answers
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