Before using the GROUP BY clause, we need to know some important provisions


GROUP BY clause can contain any number of columns, and thus packets may be nested, the data packets in more detail.
If the packet is nested in the GROUP BY clause, data will be summarized in the last packet specified. In other words, when the establishment of a packet, all columns are calculated with the specified (it is not
the individual data retrieved from the column).
Each column GROUP BY clause must be listed in the column or retrieve valid expression (but are not aggregate functions). If you use an expression in a SELECT, you must be in the GROUP BY
specify the same expression sentence. You can not use an alias.
Most implementations do not allow SQL GROUP BY column data types (such as text or memo field) with a variable length.
In addition to statements gathered outside the calculation, each column in the SELECT statement must be given in the GROUP BY clause.
If the packet contains a column of the row with a NULL value, then return NULL as one packet. If a NULL value in the column a plurality of rows, they will be divided into one group.
After the GROUP BY clause must appear in the WHERE clause, ORDER BY clause before.

Guess you like

Origin blog.csdn.net/qq_41782949/article/details/84999715