Oracle中的聚合函数 rank()

rank() over(partition by A order by B asc|desc)
A为分集字段,B为集内排序字段

典型案例:
找出某个日期每个营业部内资产数额排名前两位的顾客
select * from (select rank() over(partition by branch_no order by asset desc) rk,account,asset from aa.asset)
where rk<=2

猜你喜欢

转载自andy-li-chn.iteye.com/blog/1564760