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

Visualization Road (IX) detailed explanation of arrow class

组合数求解与(扩展)卢卡斯定理

On BFC (block formatting context)

可视化常见绘图(三)面积图

Discussion on arrow function of ES6

Discussion on the outline of short video technology

数据分析入门 | kaggle泰坦尼克任务(三)—>探索数据分析

Discussion on frame construction and technology selection of short video platform

Source Insight 4.0常见问题

页面动态显示时间(升级版)
随机推荐
Transformer的pytorch实现
npm 安装踩坑
刨根问底---cocos2d源码的理解与分析
7.子查询
Machine vision series (02) -- tensorflow2 3 + win10 + GPU installation
12.约束
[self motivation series] you'll never be ready
如何将进程绑定到指定的CPU上
如何SQL 语句UNION实现当一个表中的一列内容为空时则取另一个表的另一列
常用的DOS命令
[Educational Codeforces Round 80] 解题报告
H5案例开发
理解补码的要点
Lead the industry trend with intelligent production! American camera intelligent video production platform unveiled at 2021 world Ultra HD Video Industry Development Conference
Machine vision series (01) -- Overview
[2020WC Day2]F.采蘑菇的克拉莉丝(子树和查询、轻重儿子思想)
小程序wx.previewMedia相关问题解决-日常踩坑
2022.3.14 阿里笔试
王者荣耀-unity学习之旅
6.聚合函数和分组统计