数据库

 首页 > 数据库 > MySql > Oracle分析函数PERCENTILE_CONT

Oracle分析函数PERCENTILE_CONT

分享到:
【字体:
导读:
         摘要:查询各部门中薪水分布处于25%、50%、75%位置的人的薪水,percent_rank()是确定排行中的相对位置。SQL> select e.ename,e.sal,e.deptno,       percent_rank() over(partition by deptn...

Oracle分析函数PERCENTILE_CONT

查询各部门中薪水分布处于25%、50%、75%位置的人的薪水,percent_rank()是确定排行中的相对位置

SQL> select e.ename,e.sal,e.deptno,

       percent_rank() over(partition by deptno order by sal desc) p_rank,
       PERCENTILE_CONT(0) within group(order by sal desc)
        over(partition by deptno) max_sal ,
       PERCENTILE_CONT(0.25) within group(order by sal desc)
        over(partition by deptno) max_sal_25,
       PERCENTILE_CONT(0.5) within group(order by sal desc)
        over(partition by deptno) max_sal_50,
       PERCENTILE_CONT(0.75) within group(order by sal desc)
        over(partition by deptno) max_sal_75
    from emp e;
ENAME             SAL     DEPTNO     P_RANK    MAX_SAL MAX_SAL_25 MAX_SAL_50 MAX_SAL_75
---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
KING             5000         10          0       5000       3725       2450       1875
CLARK            2450         10         .5       5000       3725       2450       1875
MILLER           1300         10          1       5000       3725       2450       1875
SCOTT            3000         20          0       3000       3000       2975       1100
FORD             3000         20          0       3000       3000       2975       1100
JONES            2975         20         .5       3000       3000       2975       1100
ADAMS            1100         20        .75       3000       3000       2975       1100
SMITH             800         20          1       3000       3000       2975       1100
BLAKE            2850         30          0       2850       1575       1375       1250
ALLEN            1600         30         .2       2850       1575       1375       1250
TURNER           1500         30         .4       2850       1575       1375       1250
WARD             1250         30         .6       2850       1575       1375       1250
MARTIN           1250         30         .6       2850       1575       1375       1250
JAMES             950         30          1       2850       1575       1375       1250
已选择14行。


SQL> select e.ename,e.sal,e.deptno,
         percent_rank() over(partition by deptno order by sal) p_rank,
         PERCENTILE_CONT(0) within group(order by sal)
          over(partition by deptno) max_sal ,
         PERCENTILE_CONT(0.25) within group(order by sal)
          over(partition by deptno) max_sal_25,
         PERCENTILE_CONT(0.5) within group(order by sal)
          over(partition by deptno) max_sal_50,
         PERCENTILE_CONT(0.75) within group(order by sal)
          over(partition by deptno) max_sal_75
      from emp e;
ENAME             SAL     DEPTNO     P_RANK    MAX_SAL MAX_SAL_25 MAX_SAL_50 MAX_SAL_75
---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
MILLER           1300         10          0       1300       1875       2450       3725
CLARK            2450         10         .5       1300       1875       2450       3725
KING             5000         10          1       1300       1875       2450       3725
SMITH             800         20          0        800       1100       2975       3000
ADAMS            1100         20        .25        800       1100       2975       3000
JONES            2975         20         .5        800       1100       2975       3000
SCOTT            3000         20        .75        800       1100       2975       3000
FORD             3000         20        .75        800       1100       2975       3000
JAMES             950         30          0        950       1250       1375       1575
MARTIN           1250         30         .2        950       1250       1375       1575
WARD             1250         30         .2        950       1250       1375       1575
TURNER           1500         30         .6        950       1250       1375       1575
ALLEN            1600         30         .8        950       1250       1375       1575
BLAKE            2850         30          1        950       1250       1375       1575
已选择14行。
Oracle分析函数PERCENTILE_CONT
分享到:
安装MYSQL错误“conflicts with file fro...
安装MYSQL错误“conflicts with file from package mysql-libs-*” 解决方法安装MYSQL的时候时: 错误现象: [root@localhost opt]# rpm -ivh MySQL-server-5.5.32-1.el6.x86_64.rpm Preparing... ########################################### [100%] file /usr/share/mysql/charsets/Index.xml from i...
Oracle not exists的等价写法
Oracle not exists的等价写法  not exists可以改为left join + is null,可以看到改写前后执行计划一样,消耗资源一样,说明完全等价。 SQL> drop table test purge; SQL> drop table test1 purge; SQL> create table test as select * from dba_objects; SQL> create table test1 as select * from dba_objects; SQL> del...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……