(用到3个地方:分组列、组内排序列、表名)
oracle:
select t.*
from
(
select a.*, ROW_NUMBER() OVER (PARTITION BY 分组列 ORDER BY 组内排序列 DESC) rn
from 表名 a
) t
where t.rn = 1
select t.* from (
select a.*, ROW_NUMBER() OVER (PARTITION BY 分组列 ORDER BY 组内排序列 DESC) rn_001
from 表名 a
) t where t.rn_001 = 1
转载地址: