当前位置:网站首页>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面试】第一时间阅读,回复【资料】获取福利,回复【项目】获取项目源码,回复【简历模板】获取简历模板,回复【学习路线图】获取学习路线图。
边栏推荐
猜你喜欢

What are the constraints in MySQL? (instance verification)

U盘内存卡数据丢失怎么恢复,这样操作也可以

实战回忆录:从Webshell开始突破边界

互斥量互斥锁

Flutter 文件读写-path_provider
A method to quickly connect notebook computers to mobile phone hotspots

Flutter file read / write -path_ provider
![[domain penetration authorization] cve-2020-1472 Netlogon privilege escalation vulnerability](/img/1a/916915b32e5adaf86b210fc764dbf6.png)
[domain penetration authorization] cve-2020-1472 Netlogon privilege escalation vulnerability
笔记本电脑快速连接手机热点的方法

ThreadLocal线程变量
随机推荐
Stm32 usart+dma usage based on Hal Library
【LoRaWAN节点应用】安信可Ra-08/Ra-08H模组入网LoRaWAN网络的应用及功耗情况
Voice annotation automatic segment alignment tool sppas usage notes
使用adb命令调试夜神模拟器
[quantitative investment system] factor processing and installation Talib
馬賽克筆記
Code:: blocks code formatting shortcuts
Open an account to buy funds. Is it safe to open an account through online funds-
Why are two SQL statements that execute very fast, especially after the Union
Hook 簡介
Want to open a stock account, is it safe to open a stock account online-
After crossing, she said that the multiverse really exists
NP5 格式化输出(三)
STM32基于HAL库的USART+DMA使用
马赛克笔记
php 清除多维数组里面的空值
PostgreSQL installation: the database cluster initialization failed, stack hbuilder installation
变形金刚Transformer详解
[eye of depth wuenda machine learning homework class phase IV] summary of logistic regression
在colaboratory上云端使用GPU训练(以YOLOv5举例)