1.1: 字段分区数值汇总
oracle中分析函数
–分析函数 分区
select t.e_no,
t.e_deptno,
t.e_sal,
sum(t.e_sal) over(partition by t.e_deptno) as sumSal, --按部门分区汇总部门员工工资总和不排序
sum(t.e_sal) over(partition by t.e_deptno order by t.e_sal) sumSal2, --按部门分区且排序
sum(t.e_sal) over() sumSal3 --不分区汇总所有工资
from employee t;
oracle中分析函数
1.2 :字段分区后排序
–分析函数 分区排序
select t.e_no,
t.e_deptno,
t.e_sal,
rank() over(partition by t.e_deptno order by t.e_sal) rankSal, --相同e_sal 排名一致且相同的排名一致且 占位
dense_rank() over(partition by t.e_deptno order by t.e_sal) denseSal, --相同e_sal 排名一致 且相同的排名不占位
row_number() over(partition by t.e_deptno order by t.e_sal) rowSal – 相同e_sal 一次排名,不存在并列
from employee t;
oracle中分析函数

相关文章: