首页 > 技术文章 > oracle分组后取某组中最大的值

Alwaysbecoding 2019-01-11 17:47 原文

 

查询username,根据fundcode分组,按照date倒序,取date最大的一条数据

select * from ( 
select username, row_number() over(partition by fundcode, order by date desc) rn 
from usertable
) t where t.rn <=1

 

 

 

-----------------------------------------------------------------------------

 

推荐阅读