select distinct
user_id,
last_value(date) over(partition by user_id order by date rows between current row and unbounded following) as d
from login; 
select distinct
user_id,
last_value(date) over(partition by user_id order by date rows between current row and unbounded following) as d
from login;