oracle分组后取某组中最大的值

查询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

猜你喜欢

转载自www.cnblogs.com/Alwaysbecoding/p/10256473.html