oracle 同一个ID 有多条记录,怎么取每个ID时间最大的那一条

假设表为Table,ID字段为ID,时间字段为time

select *
  from (select row_number() over(partition by id order by time desc) rn, a.*
           from table a)
 where rn = 1

以上。

温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-11-09
select id,max(time) from table group by id;

本回答被网友采纳
第2个回答  2019-05-15
先通过时间倒序,然后用id分组就出来了
select * from (select * from table order by time) as a group by a.id