当前位置:网站首页>Oracle-子查询
Oracle-子查询
2022-06-29 07:40:00 【旷世奇才李先生】
工欲善其事必先利其器
文章持续更新,可以微信搜索【小奇JAVA面试】第一时间阅读,回复【资料】获取福利,回复【项目】获取项目源码,回复【简历模板】获取简历模板,回复【学习路线图】获取学习路线图。

文章目录
一、子查询
exists():判断,如果子查询有返回数据,那么就执行外部查询
1、查询学生中年龄最小的学生信息
select * from student where age = (select min(age) from student);
2、查询年龄和“张三”一样大的学生信息
select * from student where age = (select age from student where name = '张三')
3、查询年龄,性别和“张三”一样的学生信息,不包括“张三”
select * from student where (age,sex) = (select age,sex from student where name = '张三')
and name <> '张三'
4、查询年龄和“张三”或者“李四”相同的学生信息
select * from student where age in (select age from student where name ='张三' or '李四')
5、如果有姓名为“张三”的学生,那么就查询出所有学生信息,如果没有姓名为“张三”的学生,就什么都不查询
select * from student where exists(select * from student where name = '张三')
二、在having中使用子查询
1、查询出班级平均分高于年级平均分的班级、平均分、班级人数
select class,count(*),avg(grade) from student group by class having avg(grade) > (select avg(grade) from student)
三、在from子句中使用子查询
1、查询学生id和老师进行班级分组后的sid相等的学生id
select s.id from student s (select t.id,t.class from teacher t group by t.class) where s.id = t.sid
四、总结
这里的相关内容还没有整理完毕,文章后面持续更新,建议收藏。
文章中涉及到的命令大家一定要像我一样每个都敲几遍,只有在敲的过程中才能发现自己对命令是否真正的掌握了。
可以微信搜索【小奇JAVA面试】第一时间阅读,回复【资料】获取福利,回复【项目】获取项目源码,回复【简历模板】获取简历模板,回复【学习路线图】获取学习路线图。
边栏推荐
- Verilog first experience
- sed 替换值为变量
- Feature selection: maximum information coefficient (MIC) [used to measure the degree of correlation between two variables X and y, linear or nonlinear strength, commonly used for feature selection of
- 【微服务|OpenFeign】openfeign的超时时间
- Mosaic notes
- [domain penetration authorization] cve-2020-1472 Netlogon privilege escalation vulnerability
- Mongodb- connect to the database using the mongo/mongosh command line
- Sed replace value with variable
- 互斥量互斥锁
- [hcie TAC] question 5-2
猜你喜欢

sql语句concat搜索不出结果

solidity部署和验证代理合约

Simple use of vlookup function in Excel -- exact matching or approximate matching data

Taro 介绍

PostgreSQL installation: the database cluster initialization failed, stack hbuilder installation

Stm32 usart+dma usage based on Hal Library

城通网盘仿蓝奏网盘源码 附带视频教程

Explain the garbage collection mechanism (GC) in JVM

A review of visual SLAM methods for autonomous driving vehicles

aws elastic beanstalk入门之简单使用
随机推荐
语音处理工具:sox
苹果开发者容易招致调查的若干行为
Audio and video development cases 99 lectures - Contents
互斥量互斥锁
What does Ali's 211 mean?
[eye of depth Wu Enda's fourth operation class] summary of multiple linear regression with multiple variables
Hands on deep learning (I) -- linear neural network
Np5 formatted output (III)
[Kerberos] analysis of Kerberos authentication
[eye of depth wuenda machine learning homework class phase IV] regularization regularization summary
Debugging nocturnal simulator with ADB command
Seven common sorts
P6772 [NOI2020] 美食家(矩阵快速幂)
【LoRaWAN节点应用】安信可Ra-08/Ra-08H模组入网LoRaWAN网络的应用及功耗情况
Verilog初体验
华为设备配置中型网络WLAN基本业务
dcase_ Util tutorial
Protobuf binary file learning and parsing
NP5 格式化输出(三)
【微服务|OpenFeign】openfeign的超时时间