61.Oracle数据库SQL开发之 高级查询——使用分析函数之反百分点函数
欢迎转载,转载请标明出处:http://blog.csdn.net/notbaron/article/details/49847041
反百分比函数由两个:PERCENTILE_DISC(x)和PERCENTILE_CONT(x).作用与CUME_DIST和PERCENT_RANK()相反。PERENTILE_DISC在每一个分组中检查累积分布的数值,直到找到大于或等于X的值。PERCENTILE_CONT(X)在每一个分组中检查百分比排名的值,直到找到大于或者等于X的值。
select percentile_cont(0.6) within group (order bysum(amount) desc) as percentile_cont,
percentile_disc(0.6) within group (order by sum(amount) desc) aspercentile_disc
fromall_sales where year=2003 group by prd_type_id;
PERCENTILE_CONTPERCENTILE_DISC
--------------- ---------------
417855.11 402751.16