当前位置:网站首页>The difference between having and where in SQL
The difference between having and where in SQL
2022-04-23 14:50:00 【Jan_ ssen】
stay SQL in , General addition, deletion, query and modification statements use WHERE Keywords to retrieve special fields , But when SELECT Used in query statements GROUP BY For grouping queries , For conditional filtering of grouped results, you need HAVING key word .
Simply speaking , Namely WHERE Used before grouping ,HAVING Used after grouping !
for example , Find the average score of classes with class number less than four
SELECT class, AVG(score)
FROM test
WHERE class<4
GROUP BY class;
SELECT class, AVG(score)
FROM test
GROUP BY class
HAVING class<4;
Both of the above expressions are correct , But the former is to filter first and then group , The latter is to group first and then filter .
Of course , This example is just one by one , In many cases, you must filter the grouped data , that HAVING It'll come in handy .
版权声明
本文为[Jan_ ssen]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231446553533.html
边栏推荐
- Want to be an architect? Tamping the foundation is the most important
- 【NLP】HMM隐马尔可夫+维特比分词
- Interviewer: let's talk about the process of class loading and the mechanism of class loading (parental delegation mechanism)
- ASEMI整流模块MDQ100-16在智能开关电源中的作用
- January 1, 1990 is Monday. Define the function date_ to_ Week (year, month, day), which realizes the function of returning the day of the week after inputting the year, month and day, such as date_ to
- A blog allows you to learn how to write markdown on vscode
- 1n5408-asemi rectifier diode
- Model location setting in GIS data processing -cesium
- [NLP] HMM hidden Markov + Viterbi word segmentation
- 一个月把字节,腾讯,阿里都面了,写点面经总结……
猜你喜欢

Comment eolink facilite le télétravail

MySQL报错packet out of order

【STC8G2K64S4】比较器介绍以及比较器掉电检测示例程序

QT interface optimization: QT border removal and form rounding

MySQL error packet out of order

【无标题】

博睿数据携手F5共同构建金融科技从代码到用户的全数据链DNA

外包幹了四年,廢了...

Don't you know the usage scenario of the responsibility chain model?

UML project example -- UML diagram description of tiktok
随机推荐
Raised exception class eaccexviolation with 'access violation at address 45efd5 in module error
pnpm安装使用
capacitance
Swift:Entry of program、Swift调用OC、@_silgen_name 、 OC 调用Swift、dynamic、String、Substring
Unity_代码方式添加绑定按钮点击事件
A good tool: aardio
1 minute to understand the execution process and permanently master the for cycle (with for cycle cases)
Explain TCP's three handshakes in detail
Vous ne connaissez pas encore les scénarios d'utilisation du modèle de chaîne de responsabilité?
8.5 循环神经网络简洁实现
Is asemi ultrafast recovery diode interchangeable with Schottky diode
Leetcode151 - invert words in string - String - simulation
AT89C52 MCU frequency meter (1Hz ~ 20MHz) design, LCD1602 display, including simulation, schematic diagram, PCB and code, etc
线程同步、生命周期
We reference My97DatePicker to realize the use of time plug-in
面试官:说一下类加载的过程以及类加载的机制(双亲委派机制)
全连接层的作用是什么?
Arduino for esp8266串口功能简介
1N5408-ASEMI整流二极管1N5408
1n5408-asemi rectifier diode