Data grouping
The GROUP BY clause can contain any number of columns and be nested so that the data is aggregated in the last set of groupings.
Each column listed in the GROUP BY clause must be a retrieval column or a valid expression (but not a clustered function), and if you use an expression in select, you must specify the same expression in the GROUP BY clause, and you cannot use an alias.
Each column in a SELECT statement must be given in the GROUP BY clause in addition to the clustered calculation statement.
The null values in the grouping column are separated into a separate set
Having is used to filter groups such as:
Select Cust_id,count (*) as orders from orders group by CUST_ID have Count (*) >=2;
Where the data is filtered before grouping, having to filter after grouping
Statement order: Select, from, where, group by, have, order by, limit
Establish sub-query skills: first establish and test the most internal query, and then use hard-coded data to build and test the outer query, and do not embed the subquery until it is OK.
"MySQL must know" note (iv)