1. Aggregate Function 1.1.COUNT () function 1. the COUNT () function is used to COUNT the number of records. 2. it is used with the GOUPEBY keyword. I still use the t_student table here. You can create a table by yourself and it is not necessary to be exactly the same as me. example: query the total number of students in the t_student table MysqlSELECTCOUNT (*) AStotalFR
1. Aggregate Function 1.1. COUNT () function 1. the COUNT () function is used to COUNT the number of records. 2. it is used together with the goupe by keyword. I still use the t_student table here. you can create your own table exercises without having to be exactly the same as me. example: query the total number of students in the t_student table MysqlSELECT COUNT (*) AS 'Total' FR
Zookeeper
I. Aggregate functions
1.1. COUNT () function
1. The COUNT () function is used to COUNT the number of records;
2. Used with the goupe by keyword;
I am still using the t_student table. You can create a table on your own and do not need to be exactly the same as me.
For example, query the total number of students in the t_student table.
Mysql> select count (*) AS 'Total' FROM t_student;
Example: query the number of students in each grade in the t_student table.
Mysql> select count (*) AS 'Total', gradeName FROM t_student group by gradeName;
1.2. SUM () function
1. The SUM () function is the SUM function;
2. Used with the goupe by keyword;
Example: query the total age of all students in the t_student table.
Mysql> select sum (age) AS 'Age SUM 'FROM t_student;
For example, query the total age of all students in the t_student table and group them by grade.
Mysql> select sum (age) AS 'Age sume', gradeName FROM t_student group by gradeName;
1.3. AVG () function
1. The AVG () function is a function used to calculate the average value;
2. Used with the goupe by keyword;
For example, query the average age of all students in the t_student table.
Mysql> select avg (age) AS 'average age' FROM t_student;
For example, query the average age of all students in the t_student table and group them by grade.
Mysql> select avg (age) AS 'average age', gradeName FROM t_student group by gradeName;
1.4. MAX () function
1. the MAX () function is the function for finding the maximum value;
2. Used with the goupe by keyword;
For example, the largest age among all students in the t_student table is queried.
Mysql> select max (age) AS 'maximum age' FROM t_student;
Example: query the t_student table for students of the largest age in each grade.
Mysql> select max (age) AS 'maximum age', gradeName FROM t_student group by gradeName;
1.5. MIN () function
1. The MIN () function is the function for minimum value;
2. Used with the goupe by keyword;
Example: query the t_student table for all the youngest students
Mysql> select min (age) AS 'minimum age' FROM t_student;
Example: query the t_student table for the youngest student in each grade.
Mysql> select min (age) AS 'minimum age', gradeName FROM t_student group by gradeName;