dan_N.
dan_N.

Reputation: 11

Retrieve latest timestamp in table

I've a table with primary id and timestamp fields and there are many rows with different timestamps. I want to retrieve the row for which the latest timestamp is there for a specific id. The timestamp is in UNIX timestamp format. How do I retrieve that specific row?

Upvotes: 0

Views: 33

Answers (2)

subodh
subodh

Reputation: 6158

Try using this:

select * from table where id=1 order by timestamp_field desc;

Upvotes: 0

vathek
vathek

Reputation: 551

select id, max(timestamp)
from table 
group by id 

Hope helped you!

Upvotes: 1

Related Questions