当前位置:网站首页>6. Aggregation function and grouping statistics
6. Aggregation function and grouping statistics
2022-04-23 07:40:00 【Ah Dai cloth clothes cool】
6. Aggregate function and grouping statistics
1. Inquiry Department 30 The total number of people
select count(empno) The total number of
from emp
where deptno=30;
2. Inquiry Department 30 The highest wage of 、 minimum wage 、 Average wage
select max(sal),min(sal),round(avg(sal),2)
from emp
where deptno=30;
3. Query the average salary of each department
select deptno Department number ,avg(sal) Average wage
from emp
group by deptno;
select d.dname Department name ,avg(sal) Average wage
from emp e,dept d
where e.deptno=d.deptno
group by d.dname;
4. Query the name of the Department and the number of employees in each department
select d.dname Department name ,count(e.empno) Number of employees
from dept d
left join emp e on d.deptno=e.deptno
group by d.dname;
5. Query the average wage greater than 2000 The department number and average salary of
select deptno,avg(sal)
from emp
group by deptno
having avg(sal)>2000;
6. Find the position name of non salesperson , And the total monthly salary of employees engaged in the same work , And the total salary shall be greater than 5000, The query results are arranged in ascending order of the sum of monthly wages
select job,sum(sal) sum
from emp
where job!='saleman'
group by job
having sum(sal)>5000
order by sum;
版权声明
本文为[Ah Dai cloth clothes cool]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230622239378.html
边栏推荐
猜你喜欢
随机推荐
anaconda3安装
F-牛妹的苹果树(直径合并)
Transformer的pytorch实现
学习笔记5-梯度爆炸和梯度消失(K折交叉验证)
数据分析学习(一)数据分析和Numpy基础
manjaro安装与配置(vscode,微信,美化,输入法)
每日一题 | 曾被反转链表支配的恐惧
[hdu6833]A Very Easy Math Problem(莫比乌斯反演)
Discussion on arrow function of ES6
如何将进程绑定到指定的CPU上
ES6之箭头函数细谈
Mysql隔离级别
可视化常见问题解决方案(八)共享绘图区域问题解决方案
【TED系列】如何与内心深处的批评家相处?
[COCI] Vještica (子集dp)
Applet newline character \ nfailure problem resolution - Daily pit stepping
1. View databases and tables
快速傅里叶变换FFT简明教程
反思 | 事件总线的局限性,组件化开发流程中通信机制的设计与实现
xdotool按键精灵