select * from (select row_number() over(partition by id order by time desc) rn, a.* from table a) where rn = 1
以上。
select id,max(time) from table group by id;
先通过时间倒序,然后用id分组就出来了select * from (select * from table order by time) as a group by a.id