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?

How to use Groups function in MySQL SELECT clause?

王林
王林forward
2023-09-12 17:37:02878browse

如何在 MySQL SELECT 子句中使用 Groups 函数?

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.

Example

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete