select u_n,c_n,date from(select u.name u_n,c.name c_n,date,row_number()over(partition by u.name order by date desc) rn from login l join user u on l.user_id=u.id join client c on l.client_id=c.id) t where rn=1 order by u_n
select u_n,c_n,date from(select u.name u_n,c.name c_n,date,row_number()over(partition by u.name order by date desc) rn from login l join user u on l.user_id=u.id join client c on l.client_id=c.id) t where rn=1 order by u_n