当前位置:网站首页>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
边栏推荐
猜你喜欢
# 可视化常见绘图(二)折线图
javscript获取文件真实后缀名
Lead the industry trend with intelligent production! American camera intelligent video production platform unveiled at 2021 world Ultra HD Video Industry Development Conference
How does the public and Private Integrated walkie talkie realize cooperative work under multi-mode communication?
组合数求解与(扩展)卢卡斯定理
保洁阿姨都能看懂的中国剩余定理和扩展中国剩余定理
[Educational Codeforces Round 80] 解题报告
自定义钉钉机器人进行报警
可视化常见问题解决方案(八)数学公式
免费开源智能充电桩物联网SAAS云平台
随机推荐
Metro wireless intercom system
go语言数组操作
xdotool按键精灵
自定义classloader并实现热部署-使用loadClass
Take you to travel in space, and American photography technology provides comprehensive technical support for aerospace creative applet
javscript获取文件真实后缀名
数据分析入门 | kaggle泰坦尼克任务(三)—>探索数据分析
Background management system framework, there is always what you want
1D/1D动态规划学习总结
小程序wx.previewMedia相关问题解决-日常踩坑
安装tui-editor失败,快速解决方案
jvm知识点汇总-持续更新
H5案例开发
ES6之箭头函数细谈
小程序换行符\n失效问题解决-日常踩坑
Patrol inspection intercom communication system in power industry
Educational Codeforces Round 81 (Rated for Div. 2)
按需引入vant组件
记录一下使用v-print中遇到的问题
Discussion on arrow function of ES6