I have a table with columns user_id, time_stampand activitywhich I use to transcode user actions for the audit log.
user_id
time_stamp
activity
Now I would like to get the latest timestamp for each unique one user_id. How to do it?
SELECT MAX(time_stamp), user_id FROM table GROUP BY user_id;
The following query should be what you want ...
select user_id,max(time_stamp) from yourtable group by user_id order by user_id, time_stamp desc