Oracle 多行函数
来源:互联网 发布:51信用卡待遇 知乎 编辑:程序博客网 时间:2024/06/06 00:31
工资总额
select sum(sal) from emp;
SUM(SAL) ---------- 29025
人数
select count(*) from emp;
COUNT(*) ---------- 14
平均工资
select sum(sal)/count(*) 一,avg(sal) 二 from emp;
一 二 ---------- ---------- 2073.21429 2073.21429
平均奖金
select sum(comm)/count(*) 一,sum(comm)/count(comm) 二,avg(comm) 三 from emp;
一 二 三 ---------- ---------- ---------- 157.142857 550 550
select count(*),count(comm) from emp;
COUNT(*) COUNT(COMM) ---------- ----------- 14 4
多个列的分组
select deptno,job,sum(sal) from emp group by deptno,job order by 1;
DEPTNO JOB SUM(SAL) ---------- --------- ---------- 10 CLERK 1300 10 MANAGER 2450 10 PRESIDENT 5000 20 ANALYST 6000
过滤分组数据
–查询平均工资大于2000的部门
select deptno,avg(sal) from emp group by deptno having avg(sal)>2000;
DEPTNO AVG(SAL) ---------- ---------- 20 2175 10 2916.66667
where和having最大的区别:where后面不能使用组函数
–查询10号部门的平均工资
select deptno,avg(sal) from emp group by deptno having deptno=10;
DEPTNO AVG(SAL) ---------- ---------- 10 2916.66667
group by的增强
select deptno,job,sum(sal) from emp group by deptno,job+select deptno,sum(sal) from emp group by deptno+select sum(sal) from emp==========================select deptno,job,sum(sal) from emp group by rollup(deptno,job);group by rollup(a,b)=group by a,b+group by a+group by null
———————————————-
select deptno,job,sum(sal) from emp group by rollup(deptno,job);
DEPTNO JOB SUM(SAL) ---------- --------- ---------- 10 CLERK 1300 10 MANAGER 2450 10 PRESIDENT 5000 10 8750 20 CLERK 1900 20 ANALYST 6000 20 MANAGER 2975 20 10875 30 CLERK 950 30 MANAGER 2850 30 SALESMAN 5600
0 0
- Oracle多行函数
- oracle 多行函数
- Oracle 多行函数
- oracle 多行函数
- oracle多行函数
- Oracle单行函数和多行函数
- Oracle多行函数(组函数)
- Oracle多行函数/组函数
- oracle--5.多行函数
- oracle函数之多行函数
- Oracle多行记录合并自定义函数
- oracle--多行转为一行 (listagg函数)
- oracle数据库的多行函数
- Oracle数据库(四)多行函数
- oracle 多行合一 wm_concat 函数
- Oracle单行函数和多行函数实例
- Oracle单行函数和多行函数实例
- ORACLE单行函数与多行函数之一
- eclipse快捷键总结(持续更新)
- 6.HCNA-HNTD——ARP协议
- 使用多路径在Oracle Linux 6.5上搭建Oracle RAC 11.2.0.4
- 求职应聘C++复习小结
- 在Android模拟器中部署apk文件
- Oracle 多行函数
- 实时调度之FIFO
- LeetCode 45.Jump Game II
- HDU 1264 Counting Squares
- 寒城攻略:Listo 教你 25 天学会 Swift 语言 - 08 Functions
- Swift UI专项训练7 数据添加
- 前端跨域杂谈
- 5款替代微软Visio的开源免费软件
- SpringMVC中的XXE漏洞测试