当前位置:网站首页>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
边栏推荐
- Explanation and example application of the principle of logistic regression in machine learning
- Master in minutes --- ternary operator (ternary operator)
- 解决computed属性与input的blur事件冲突问题
- ASEMI三相整流桥和单相整流桥的详细对比
- Daily question - leetcode396 - rotation function - recursion
- Introduction to Arduino for esp8266 serial port function
- Explain TCP's three handshakes in detail
- 2-GO variable operation
- 2-Go变量操作
- LeetCode151-颠倒字符串中的单词-字符串-模拟
猜你喜欢

Detailed comparison between asemi three-phase rectifier bridge and single-phase rectifier bridge

Swift: entry of program, swift calls OC@_ silgen_ Name, OC calls swift, dynamic, string, substring

Mds55-16-asemi rectifier module mds55-16

LeetCode167-两数之和II-双指针-二分-数组-查找

【Servlet】Servlet 详解(使用+原理)

电容

【JZ46 把数字翻译成字符串】

Using MATLAB programming to realize the steepest descent method to solve unconstrained optimization problems

Find daffodils - for loop practice

555 timer + 74 series chip to build eight way responder, 30s countdown, proteus simulation, etc
随机推荐
GIS数据处理-cesium中模型位置设置
Set up an AI team in the game world and start the super parametric multi-agent "chaos fight"
拼接hql时,新增字段没有出现在构造方法中
Bingbing learning notes: take you step by step to realize the sequence table
51 MCU + LCD12864 LCD Tetris game, proteus simulation, ad schematic diagram, code, thesis, etc
Detailed comparison between asemi three-phase rectifier bridge and single-phase rectifier bridge
QT actual combat: Yunxi chat room
ASEMI超快恢复二极管与肖特基二极管可以互换吗
博睿数据携手F5共同构建金融科技从代码到用户的全数据链DNA
51 MCU flowers, farmland automatic irrigation system development, proteus simulation, schematic diagram and C code
Select receives both normal data and out of band data
LeetCode153-寻找旋转排序数组中的最小值-数组-二分查找
epoll 的EPOLLONESHOT 事件———实例程序
The initial C language framework is suitable for review and preliminary understanding
LeetCode167-两数之和II-双指针-二分-数组-查找
Comment eolink facilite le télétravail
ArrayList collection basic usage
全连接层的作用是什么?
MySQL error packet out of order
ASEMI三相整流桥和单相整流桥的详细对比