mysql third group by clause

Syntax:
Group by Field 1, Field 2, ...;
Meaning:
representation of the acquired data to a given grouping fields.
The end result is the data into several groups, each as a "whole" becomes a row of data.
Special Note:
Once a group, only the "Group Information" - is a set of line

Example:
For the raw data as follows:
Here Insert Picture Description
its a "name" group:
Here Insert Picture Description
the result is:
Here Insert Picture Description

Special Note:
the results of the query packet, to be understood as the "number of rows of raw data", is divided into several groups, as a result, each row of data.
That is: a line of data represents a "set" is a collection concept, rather than a single concept.
Therefore: The information that appears in a row, should be "information group" rather than "individual information."
Thus, the information packet for the query (group by), select appearing, usually only the information in both cases:
1, the information field of the packet itself;
2, a comprehensive set of statistics, including:
(1) count values: count (field), a determined number of lines in the original data set;
(2) the maximum value: max (field), and the maximum value of this field indicates a set;
(3) the minimum value: min ( field), it indicates the minimum value of the field is obtained in a group;
(4) an average value: avg (field), the average value of this field indicates a group;
(5) the sum of the values: sum (field), indicates obtaining a set of accumulation and the field;

five or more functions, also referred to as "polymerization function"!
Example:

Here Insert Picture Description

Multi-criteria grouping:
All merchandise product table brand and origin group, and calculates the number of each group
select pinpai, chandi, count (* ) number as from product group by pinpai, chandi ;

Guess you like

Origin blog.csdn.net/qq_34608447/article/details/92600705