I have a table with columns user_id
, time_stamp
and activity
which I use for recoding user actions for an audit trail.
Now, I would just like to get the most recent timestamp for each unique 开发者_Python百科user_id
. How do I do that?
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
精彩评论