select u_n,
c_n,
date
from (
select b.name u_n,
c.name c_n,
date, RANK() OVER (PARTITION BY b.name ORDER BY date DESC) AS user_order
from login a
left join user b on a.user_id = b.id
left join client c on a.client_id = c.id
order by u_n
) k
where user_order =1