当前位置:网站首页>7. sub query
7. sub query
2022-04-23 07:40:00 【Ah Dai cloth clothes cool】
7. Subquery
1. Check the wage ratio 7566 High employee information
select *
from emp
where sal>(select sal from emp where empno=7566);
2. Query the employee's number 、 full name 、 Department name
select empno,ename,(select dname from dept where deptno=e.deptno)
from emp e;
3. Check the wage ratio 7654 high , At the same time with 7900 Information about employees engaged in the same work
select *
from emp
where sal>(
select sal from emp where empno=7654
) and job=(
select job from emp where empno=7900
);
4. Check the name of the lowest paid employee 、 Work 、 Wages
select ename,job,sal
from emp
where sal=(select min(sal) from emp);
5. Query the information of employees whose salary is higher than the average salary of the company
select *
from emp
where sal>(select avg(sal) from emp);
6. Check the number and minimum wage of each department , The minimum wage is required to be greater than or equal to the Department 30 The minimum wage
select deptno,min(sal)
from emp
group by deptno
having min(sal)>=(
select min(sal) from emp where deptno=30
);
7. Query the name of the Department 、 The number of employees in the Department 、 The average wage of the Department 、 The name of the lowest paid employee in the Department
select
(select dname from dept where deptno=e.deptno) dname,
count(empno),
avg(sal),
(select ename from emp where sal=min(e.sal)) ename
from emp e
group by deptno;
8. Check the lowest average wage job and average wage
select job,avg(sal)
from emp
group by job
having avg(sal)=(
select min(t.avg) from (select avg(sal) avg from emp group by job) t
);
9. Query the department number is greater than or equal to 20 Of employees
select * from emp
where deptno>=20;
select * from emp
where deptno in (
select deptno from dept where deptno>=20
);
10. Query salary and department 20 Any employee in the same employee information
select * from emp
where sal in (
select sal from emp where deptno=20
);
11. Find out that the salary of employees engaged in sales is greater than 1500 The employees'
select *
from (select * from emp where job='saleman') t
where t.sal>1500;
版权声明
本文为[Ah Dai cloth clothes cool]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230622239337.html
边栏推荐
猜你喜欢

Visualization Road (IX) detailed explanation of arrow class

AuthorizationServer(授权服务器的简单搭建)

可视化常见问题解决方案(九)背景颜色问题

Background management system framework, there is always what you want

h5本地存储数据sessionStorage、localStorage

王者荣耀-unity学习之旅

Javscript gets the real suffix of the file

学习笔记6-几种深度学习卷积神经网络的总结

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

Discussion on frame construction and technology selection of short video platform
随机推荐
[ACM-ICPC 2018 沈阳赛区网络预赛] J.Ka Chang (分块+dfs序)
可视化常见问题解决方案(七)画图刻度设置解决方案
数据分析入门 | kaggle泰坦尼克任务(四)—>数据清洗及特征处理
小程序wx.previewMedia相关问题解决-日常踩坑
anaconda3安装
数论分块(整除分块)
数据分析学习(一)数据分析和Numpy基础
菜菜的刷题日记 | 蓝桥杯 — 十六进制转八进制(纯手撕版)附进制转换笔记
状态同步与帧同步
13.用户和权限管理
6.聚合函数和分组统计
2.限定查询
Object. Create() principle, object Create() specification, handwritten object create(),Object. Create() usage
Javscript gets the real suffix of the file
AuthorizationServer(授权服务器的简单搭建)
学习笔记6-几种深度学习卷积神经网络的总结
配置npm
MVCC(多版本并发控制)
学习笔记5-梯度爆炸和梯度消失(K折交叉验证)
2022.3.14 阿里笔试