当前位置:网站首页>SQL foundation 9 [grouping data]
SQL foundation 9 [grouping data]
2022-07-04 07:09:00 【weixin_ forty-five million nine hundred and two thousand and ei】
The data packet
Using grouping, you can divide data into multiple logical groups , And perform aggregation calculation for each group .Create grouping
Grouping is using select Of the statement group by Clause .group by It can be considered as putting the data in a table , According to the value of the grouping field , It is divided into several different sub tables
The meaning of the above sentence : Counter table tb_order Press order_status Grouping , Return to a different order_status, And their number . give the result as follows .
*group by Clause can contain any number of columns , Thus, groups can be nested , More detailed data grouping .
* If in group by Group nested in Clause , The data will be summarized on the last specified group .
*group by Each column listed in clause must be a number of search columns or valid expressions ., If in select Using expressions in , Must be in group by Clause specifies the same expression .
* In addition to aggregate calculation statements ,select Each column in the statement must be in group by Given in Clause .
* If the grouping column null, be null Will be returned as a group .
*group by Clause must appear in where Before clause ,order by After Clause .Filter grouping
Use having Filter groups , All types of where Clause can be used having Instead of , The only difference is ,where Filter line , and having Filter grouping .

*where Filter before data grouping ,having Filter after data grouping ,where Excluded rows are not included in the group .
Enter the following example , Filter out receiver_address For the record of Zhongteng building .

Grouping and sorting
order by Sort the resulting output ,group by Group lines , But the output may not be in the order of grouping .select Clause order

边栏推荐
- tars源码分析之1
- Selection (023) - what are the three stages of event propagation?
- Cochez une colonne d'affichage dans une colonne de tableau connue
- Enter the year, month, and determine the number of days
- MySQL 45 lecture learning notes (VI) global lock
- 【FreeRTOS】FreeRTOS學習筆記(7)— 手寫FreeRTOS雙向鏈錶/源碼分析
- Code rant: from hard coding to configurable, rule engine, low code DSL complexity clock
- Tar source code analysis Part 3
- How does the recv of TCP socket receive messages of specified length?
- selenium驱动IE常见问题解决Message: Currently focused window has been closed.
猜你喜欢

【Kubernetes系列】Kubernetes 上安装 KubeSphere

Responsive mobile web test questions

Adaptive spatiotemporal fusion of multi-target networks for compressed video perception enhancement

Campus network problems

Su Weijie, a member of Qingyuan Association and an assistant professor at the University of Pennsylvania, won the first Siam Youth Award for data science, focusing on privacy data protection, etc

About how idea sets up shortcut key sets

How to share the source code anti disclosure scheme

Deep understanding of redis -- a new type of bitmap / hyperloglgo / Geo
![[Valentine's day] - you can change your love and write down your lover's name](/img/ab/402872ad39f9dc58fd27dd6fc823ef.jpg)
[Valentine's day] - you can change your love and write down your lover's name

A new understanding of how to encrypt industrial computers: host reinforcement application
随机推荐
The crackdown on Huawei prompted made in China to join forces to fight back, and another enterprise announced to invest 100 billion in R & D
2022 is probably the best year for the economy in the next 10 years. Did you graduate in 2022? What is the plan after graduation?
The difference between synchronized and lock
由于dms升级为了新版,我之前的sql在老版本的dms中,这种情况下,如何找回我之前的sql呢?
leetcode825. 适龄的朋友
Deep understanding of redis -- a new type of bitmap / hyperloglgo / Geo
Electronic Association C language level 1 35, bank interest
Code rant: from hard coding to configurable, rule engine, low code DSL complexity clock
JS common time processing functions
Vulhub vulnerability recurrence 76_ XXL-JOB
两年前美国芯片扭捏着不卖芯片,如今芯片堆积如山祈求中国帮忙
[MySQL transaction]
The number of patent applications in China has again surpassed that of the United States and Japan, ranking first in the world for 11 consecutive years
Recursive Fusion and Deformable Spatiotemporal Attention for Video Compression Artifact Reduction
[FPGA tutorial case 7] design and implementation of counter based on Verilog
Summary of June 2022
MySQL relearn 2- Alibaba cloud server CentOS installation mysql8.0
Uniapp applet subcontracting
Selection (021) - what is the output of the following code?
tars源码分析之4