select user_id,max(date) as d
from login
group by user_id
order by user_id

思路:求最近的日期用max函数对日期取最大值就好了