找到最大的日期,按照用户id分组,然后按照用户id排序就行了:
select user_id,MAX(date) as d
from login group by user_id order by user_id;