-- using window functions
select distinct
uid, first_value(utm) over (partition by uid order by id desc) last_utm
from t;
-- using join
select t.uid, t.utm last_utm
from t
join (
select max(id) max_id from t group by uid
) max_ids on max_id = id;
-- using sub-query
select t.uid, t.utm last_utm
from t
where id = (select max(id) max_id from t group by uid having max(id) = t.id);