select * from
(select t.*, row_number() over(partition by 分组字段 order by 排序字段 desc ) rn
from tablename t )
where rn=1
select *
from (select t.*,
row_number() over(partition by campaignid order by createat desc) rn
from app_campaigntype_summary t
where createat <= to_date('2015-01-09', 'yyyy-mm-dd'))
where rn = 1
来源:oschina
链接:https://my.oschina.net/u/2280055/blog/373902