How To Use Group Functions in the SELECT Clause

Q

How To Use Group Functions in the SELECT Clause? - MySQL FAQs - SQL SELECT Query Statements with GROUP BY

✍: FYIcenter.com

A

If group functions are used in the SELECT clause, they will be used on the rows that meet the query selection criteria, the output of group functions will be returned as output of the query. The following select statement returns 3 values calculate by 3 group functions on all rows of the "fyi_links" table:

mysql> SELECT COUNT(*), MAX(counts), MIN(created) 
   FROM fyi_links;
+----------+-------------+---------------------+
| COUNT(*) | MAX(counts) | MIN(created)        |
+----------+-------------+---------------------+
|        7 |           8 | 2003-01-01 00:00:00 |
+----------+-------------+---------------------+
1 row in set (0.37 sec)

2007-05-11, 4427👍, 0💬