Note: The text of all ... Represents more than one.
1. Use the Count Statistics bar number: Select count (field name ...) ) from TableName;
2. Use AVG to calculate the average of the field: Select AVG (field name) from TableName;
This can be properly expanded, such as adding conditions, renaming, and so on.
3. Sum with sum: select sum (field name) from TableName;
4. Use Max and Min to find maximum and minimum values:
5. Note: When using these functions, if there is no data in the database, Count returns 0, the other returns null;
6. Use GROUP by to Group data: Select Field name ... From tablename GROUP By field name ... , grouping, sorting, statistics and so on can be combined to use, in practical applications are also more like this:
7. Use the Group_concat () implementation to display fields in no group:
8. If you want to add a condition to a grouped query, you must use having, not where:
9. If you want to sort by using conditional grouping, the order by must be at the back of the having:
MySQL Common basic operational Syntax (vii)--statistical function and group query "command line mode"