当前位置:网站首页>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

边栏推荐
- [Mori city] random talk on GIS data (I)
- The important role of host reinforcement concept in medical industry
- [FPGA tutorial case 8] design and implementation of frequency divider based on Verilog
- notepad++如何统计单词数量
- Tar source code analysis 4
- Introduction to spark core components
- Tar source code analysis Part 3
- Pangu open source: multi support and promotion, the wave of chip industry
- CMS source code of multi wechat management system developed based on thinkphp6, with one click curd and other functions
- How notepad++ counts words
猜你喜欢

Shopping malls, storerooms, flat display, user-defined maps can also be played like this!

Chain ide -- the infrastructure of the metauniverse

Deep understanding of redis -- a new type of bitmap / hyperloglgo / Geo

Node connection MySQL access denied for user 'root' @ 'localhost' (using password: yes

Selenium driver ie common problem solving message: currently focused window has been closed

移动适配:vw/vh

Pangu open source: multi support and promotion, the wave of chip industry

CMS source code of multi wechat management system developed based on thinkphp6, with one click curd and other functions

notepad++如何统计单词数量

Crawler (III) crawling house prices in Tianjin
随机推荐
Why does the producer / consumer mode wait () use while instead of if (clear and understandable)
The cloud native programming challenge ended, and Alibaba cloud launched the first white paper on application liveliness technology in the field of cloud native
Tar source code analysis Part 7
Design of test cases
Wechat applet scroll view component scrollable view area
Novel website program source code that can be automatically collected
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
Since DMS is upgraded to a new version, my previous SQL is in the old version of DMS. In this case, how can I retrieve my previous SQL?
[network data transmission] FPGA based development of 100M / Gigabit UDP packet sending and receiving system, PC to FPGA
[MySQL transaction]
Boast about Devops
win10微软拼音输入法输入文字时候下方不出现中文提示
Adaptive spatiotemporal fusion of multi-target networks for compressed video perception enhancement
The important role of host reinforcement concept in medical industry
期末周,我裂开
Enter the year, month, and determine the number of days
Shopping malls, storerooms, flat display, user-defined maps can also be played like this!
Four sets of APIs for queues
响应式移动Web测试题
两年前美国芯片扭捏着不卖芯片,如今芯片堆积如山祈求中国帮忙