# Aggregate Functions
__*The role of aggregate functions*__
__*GROUP_CONCAT function*__
+ Performs a summary operation on a set of records
+ Returns a single record based on multiple records aggregated into the same group
+ Includes only non-null values in the results
+ Typical functions:
  + **`COUNT([distinct] expression)`**  
  + **`MIN(expression)`** , **`MAX(expression)`**  
  + **`SUM([distinct] expression)`** , **`AVG([distinct] expression)`**  
  + **`GROUP_CONCAT([distinct] expression)`**  
```8
tidb> SELECT GROUP_CONCAT(name), COUNT(*), MAX(mass) FROM universe.planets;
+---------------------------------------------------------------------------------+----------+-----------+
| GROUP_CONCAT(name)                                                              | COUNT(*) | MAX(mass) |
+---------------------------------------------------------------------------------+----------+-----------+
| Mercury,Venus,Earth,Mars,Jupiter,Saturn,Uranus,Neptune,Pluto,Proxima Centauri b |       10 |      1898 |
+---------------------------------------------------------------------------------+----------+-----------+
1 row in set (0.00 sec)

tidb> SELECT @@GROUP_CONCAT_MAX_LEN;
+------------------------+
| @@GROUP_CONCAT_MAX_LEN |
+------------------------+
|                   ~!@1024@!~ |
+------------------------+
```

------------------------------------------------------------
- **`COUNT()`**  return the number of rows retrieved
- **`COUNT(DISTINCT)`**  return the number of different values
- **`MAX()`**  return the maximum
- **`MIN()`**  return the minimum
- **`SUM()`**  return and
- **`AVG()`**  return the average
- **`GROUP_CONCAT()`**  return a string of connections

- Note:
  - Aggregate function ignore NULL values by default unless otherwise stated.
  - If you use an aggregate function in a statement that does not include a GROUP BY clause, it is equivalent to grouping all rows.