SelectCOUNT(Name),MIN(Id),AVG(Id) ,MAX(Id),COUNT(*)fromStudent;+-------------+---------+---------+--- ------+"/> SelectCOUNT(Name),MIN(Id),AVG(Id) ,MAX(Id),COUNT(*)fromStudent;+-------------+---------+---------+--- ------+">
Home >Database >Mysql Tutorial >How to use Groups function in MySQL SELECT clause?
We know that group functions operate on sets of values, that is why if group functions are used in SELECT clause, then they will be used for rows that satisfy the query selection criteria and The output of the group function will be returned as the output of the query.
In the following example, we have used some group functions in the SELECT statement. The fields of the "Student" table and the output of the statement are the output of these group functions-
mysql> Select COUNT(Name), MIN(Id), AVG(Id), MAX(Id), COUNT(*) from Student; +-------------+---------+---------+---------+----------+ | COUNT(Name) | MIN(Id) | AVG(Id) | MAX(Id) | COUNT(*) | +-------------+---------+---------+---------+----------+ | 5 | 1 | 11.0000 | 20 | 5 | +-------------+---------+---------+---------+----------+ 1 row in set (0.03 sec)
The above is the detailed content of How to use Groups function in MySQL SELECT clause?. For more information, please follow other related articles on the PHP Chinese website!