当前位置:网站首页>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
边栏推荐
猜你喜欢

保洁阿姨都能看懂的中国剩余定理和扩展中国剩余定理

Lead the industry trend with intelligent production! American camera intelligent video production platform unveiled at 2021 world Ultra HD Video Industry Development Conference

Discussion on arrow function of ES6

Date对象(js内置对象)

简易随机点名抽奖(js下编写)

页面动态显示时间(升级版)

页面实时显示当前时间

可视化之路(十)分割画布函数详解

可视化常见问题解决方案(八)数学公式

Mysql 索引
随机推荐
快速傅里叶变换FFT简明教程
积性函数与迪利克雷卷积
青龙面板拉库命令更新【2022/4/20】收藏不走丢
[牛客练习赛68]牛牛的粉丝(矩阵快速幂之循环矩阵优化)
npm 安装踩坑
Object. Create() principle, object Create() specification, handwritten object create(),Object. Create() usage
直观理解熵
小程序换行符\n失效问题解决-日常踩坑
xdotool按键精灵
自定义时间格式(YYYY-MM-DD HH:mm:ss 星期X)
Mysql的存储引擎
HuggingFace
Background management system framework, there is always what you want
kaggle-房价预测实战
Object.create()原理,Object.create()规范,手写Object.create(),Object.create()用法
页面动态显示时间(升级版)
数据分析学习(一)数据分析和Numpy基础
1D/1D动态规划学习总结
可视化之路(九)Arrow类详解
两个线程交互打印奇偶数字