select
a.name1
,a.name2
,b.m
from (
select
l.*
,u.name name1
,c.name name2
from login l
join user u
on l.user_id =u.id
join client c
on l.client_id = c.id
) a
join (
select
user_id
,max(date) m
from login
group by user_id
) b
on a.user_id =b.user_id
and a.date = b.m
order by a.name1