当前位置:网站首页>7.子查询
7.子查询
2022-04-23 06:23:00 【阿呆布衣酷】
7.子查询
1.查询工资比7566高雇员信息
select *
from emp
where sal>(select sal from emp where empno=7566);
2.查询雇员的编号、姓名、部门名称
select empno,ename,(select dname from dept where deptno=e.deptno)
from emp e;
3.查询工资比7654高,同时又与7900从事相同工作的雇员信息
select *
from emp
where sal>(
select sal from emp where empno=7654
) and job=(
select job from emp where empno=7900
);
4.查询工资最低的雇员的姓名、工作、工资
select ename,job,sal
from emp
where sal=(select min(sal) from emp);
5.查询工资高于公司平均工资的雇员信息
select *
from emp
where sal>(select avg(sal) from emp);
6.查询每个部门的编号和最低工资,要求最低工资大于等于部门30的最低工资
select deptno,min(sal)
from emp
group by deptno
having min(sal)>=(
select min(sal) from emp where deptno=30
);
7.查询部门的名称、部门的员工数、部门的平均工资、部门的最低收入雇员的姓名
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.查询平均工资最低的工作及平均工资
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.查询所在部门编号大于等于20的雇员信息
select * from emp
where deptno>=20;
select * from emp
where deptno in (
select deptno from dept where deptno>=20
);
10.查询工资与部门20中的任意员工相同的雇员信息
select * from emp
where sal in (
select sal from emp where deptno=20
);
11.在所在从事销售工作的雇员中找出工资大于1500的员工
select *
from (select * from emp where job='saleman') t
where t.sal>1500;
版权声明
本文为[阿呆布衣酷]所创,转载请带上原文链接,感谢
https://adbycool.blog.csdn.net/article/details/124346288
边栏推荐
- Discussion on arrow function of ES6
- 免费开源充电桩物联网云平台
- Solution of self Networking Wireless Communication intercom system in Beifeng oil and gas field
- The people of Beifeng have been taking action
- 特殊成员与魔法方法
- [CF 1425D]Danger of Mad Snakes(组合计数+容斥)
- 可视化之路(十一)matplotlib颜色详解
- Intelligent communication solution of Hainan Phoenix Airport
- H5案例开发
- VScode
猜你喜欢

菜菜的刷题日记 | 蓝桥杯 — 十六进制转八进制(纯手撕版)附进制转换笔记

Metro wireless intercom system

可视化常见问题解决方案(八)数学公式
![[Educational Codeforces Round 80] 解题报告](/img/54/2fd298ddce3cd3e28a8fe42b3b8a42.png)
[Educational Codeforces Round 80] 解题报告

Solution of self Networking Wireless Communication intercom system in Beifeng oil and gas field

Emergency air space integrated communication system scheme of Guangxi Power Grid

利用mysql-binlog恢复数据

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

Educational Codeforces Round 81 (Rated for Div. 2)

Javscript gets the real suffix of the file
随机推荐
Patrol inspection intercom communication system in power industry
快速下载vscode的方法
USO technology was invited to share the technical framework and challenges of AI synthetic virtual characters at lvson2020 conference
记录一些npm 有关的问题(杂乱记录)
Transformer的pytorch实现
菜菜的刷题日记 | 蓝桥杯 — 十六进制转八进制(纯手撕版)附进制转换笔记
Emergency communication system for flood control and disaster relief
PyTorch 20. Pytorch tips (continuously updated)
Statement of American photography technology suing Tianmu media for using volcanic engine infringement code
小程序wx.previewMedia相关问题解决-日常踩坑
积性函数前缀和——杜教筛
Beifeng communication helps Zhanjiang fire brigade build PDT wireless communication system
el-select 中v-model绑定值,数据回显只显示value,不显示label
浅谈BFC(块格式化上下文)
可视化之路(十)分割画布函数详解
1D/1D动态规划学习总结
VScode
Discussion on arrow function of ES6
H5 case development
利用mysql-binlog恢复数据