当前位置:网站首页>Database SQL language 04 subquery and grouping function
Database SQL language 04 subquery and grouping function
2022-06-30 05:22:00 【Chao Ge 1986】
Subquery
What is subquery ?
In a query statement WHERE In the conditional clause , Another query statement is nested
Nested queries can consist of multiple subqueries , The solution is from inside to outside ;
The results returned by subqueries are generally collections , Therefore, it is recommended to use IN keyword ;
– Ask for the employee information of the Department where the highest paid employee works
analysis :
First of all :
Ask for the highest salary first :
second : Ask for the department number with the highest salary :
Third : The Department is required to be 10 Employee information :
Aggregate functions

– In a sense ,count(1) And count() Both represent queries for all data rows .
– count( Field ) Count the number of times the field appears in the table , The ignored field is null The situation of . That is to say, do not count the fields as null
The record of .
– count() It includes all the columns , Equivalent to the number of lines , When it comes to statistical results , The containing field is null The record of ;
– count(1) use 1 Represents the line of code , When it comes to statistical results , The containing field is null The record of .
subject :
Ask the average salary of the Department to be greater than 2000 The department in charge of the
select avg(sal),deptno from emp
group by deptno
having avg(sal)>2000
where Written in group by front .
If you put the filter after the group
To use HAVING…
because having It's to filter from the previous fields , and where It's from the data table > Fields are filtered directly
边栏推荐
- Unity application class and data file path
- 使用码云PublicHoliday项目判断某天是否为工作日
- OpenGL draws model on QT platform to solve the problem of initializing VAO and VBO
- Revit secondary development - use panel function without opening the project
- Responsive layout
- Unity3d learning notes-1 (C # learning)
- Gradient clip in dqn
- unity 扫描圈 圆扩展方法
- Writing unityshader with sublimetext
- Display steerable 3D model in front of unity UI
猜你喜欢

遥感图像/UDA:Curriculum-Style Local-to-Global Adaptation for Cross-Domain Remote Sensing Image Segmentat

Database base (Study & review for self use)

PWN入门(2)栈溢出基础

Digital signature——

企事业单位源代码防泄露工作该如何进行

9. naive Bayes

Assembly learning tutorial: accessing memory (3)

Unity3d packaging and publishing APK process

Visualization of 3D geological model based on borehole data by map flapping software

Unity 3D model operation and UI conflict Scrollview
随机推荐
Unity notes_ SQL Function
Unity C trigonometric function, right triangle corner calculation
2021-10-31
遥感图像/UDA:Curriculum-Style Local-to-Global Adaptation for Cross-Domain Remote Sensing Image Segmentat
Chapter 8 primitive processing of OpenGL super classic (version 7)
Pytorch的安装以及入门使用
Golan no tests were run: fmt Printf() < BUG>
Tensorflow2 of ubantu18.04 X installation
Unity Catmull ROM curve
[notes] unity Scrollview button page turning
Initial environment configuration of the list of OpenGL super classic (version 7) vs2019
GoLand No Tests Were Run : 不能使用 fmt.Printf() <BUG>
Postman 做测试的 6 个常见问题
终端便捷ssh(免密)连接
Unity mobile end sliding screen rotation
Ugui uses its own function to realize reverse mask
Records of some problems encountered during unity development (continuously updated)
Xctf--Web--Challenge--area Wp
Connect() and disconnect() of socket in C #
Wechat applet training 2