题解 | #牛客每个人最近的登录日期(二)#
牛客每个人最近的登录日期(二)
https://www.nowcoder.com/practice/7cc3c814329546e89e71bb45c805c9ad
select
u_n,
c_n,
`date`
from
(
select
t3.name as u_n,
t1.name as c_n,
t2.date as `date`,
rank() over (
partition by
t2.user_id
order by
t2.date desc
) as ranking
from
client as t1
inner join login as t2 on t1.id = t2.client_id
inner join user as t3 on t2.user_id = t3.id
group by
t3.id,
u_n,
c_n,
`date`
) as tp
where ranking = 1
order by u_n asc;
