Home > Database > Mysql Tutorial > body text

What does group by mean in SQL?

anonymity
Release: 2020-10-12 17:35:12
Original
35328 people have browsed it

Group by in SQL is to group data according to the rules specified by "By", and the so-called grouping is to divide a "data set" into several "small areas", and then target several "small areas" area" for data processing.

What does group by mean in SQL?

group_by means which field or fields to group the data according to by. "Group By" literally means to group data according to the rules specified by "By". The so-called grouping is to divide a "data set" into several "small areas", and then target several "small areas". data processing.

Grammar structure is as follows:

select   字段    from   表名   where    条件     group   by       字段
或者
select   字段    from   表名   group  by    字段    having    过滤条件
Copy after login

Note: For filtering conditions, you can use where first, then group by or group by first, then having

Original table

What does group by mean in SQL?

Simple Group By

Example 1

select category, sum(quantity) as sum of quantities

from A

group by category

The return result is as shown in the table below, which is actually a summary of categories.

What does group by mean in SQL?

The above is the detailed content of What does group by mean in SQL?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!