select a.call_num,a.address as last_long_addr from (select * from tb)a, (select call_num,max(call_time) call_time from tb group by coll_num,substr(coll_time,1,6))b where a.call_num=b.call_num and a.call_time=b.call_time ;
或者 select * from (select t.*,row_number() over(partition by call_num order by call_time desc) rn from tb t) where rn=1;
from (select * from tb)a,
(select call_num,max(call_time) call_time from tb group by coll_num,substr(coll_time,1,6))b
where a.call_num=b.call_num and a.call_time=b.call_time
;
select *
from
(select t.*,row_number() over(partition by call_num order by call_time desc) rn from tb t)
where rn=1;