题解 | #牛客每个人最近的登录日期(二)#
牛客每个人最近的登录日期(二)
http://www.nowcoder.com/practice/7cc3c814329546e89e71bb45c805c9ad
select u_n, c_n, date from (select user_id, client_id, date, c_n, user.name u_n, rk from (select user_id, client_id, date, client.name c_n, rank() over(partition by user_id order by date desc) rk from login LEFT JOIN client on login.client_id = client.id) t1 left join user on t1.user_id = user.id) t2 where rk = 1 group by user_id order by u_n