题解 | #牛客每个人最近的登录日期(二)#
牛客每个人最近的登录日期(二)
https://www.nowcoder.com/practice/7cc3c814329546e89e71bb45c805c9ad
先查找到max(date) group by user_id,条件要有l.date=l2.date! select u.name as u_n, c.name as c_name , l.date as date from login l inner join (select user_id,max(date) as date from login group by user_id ) as l2 on l.user_id=l2.user_id and l.date=l2.date left join user u on u.id =l.user_id left join client c on c.id=l.client_id order by u.name;