Collections:
Dividing Query Output into Groups in MySQL
How To Divide Query Output into Groups in MySQL?
✍: FYIcenter.com
You can divide query output into multiple groups with the GROUP BY clause. It allows you specify a column as the grouping criteria, so that rows with the same value in that column will be considered as a single group. When the GROUP BY clause is specified, the select statement can only be used to return group level information. The following script gives you a good GROUP BY example:
mysql> SELECT tag, COUNT(*), MIN(created), AVG(counts) FROM fyi_links GROUP BY tag; +------+----------+---------------------+-------------+ | tag | COUNT(*) | MIN(created) | AVG(counts) | +------+----------+---------------------+-------------+ | DBA | 3 | 2005-01-01 00:00:00 | 3.6667 | | DEV | 2 | 2004-01-01 00:00:00 | 4.0000 | | SQA | 2 | 2003-01-01 00:00:00 | 7.0000 | +------+----------+---------------------+-------------+ 3 rows in set (0.07 sec)
⇒ Apply Filtering Criteria at Group Level in MySQL
⇐ Group Functions with Non-group Selections in MySQL
2017-10-16, 2780🔥, 0💬
Popular Posts:
How To Assign Debug Privileges to a User in Oracle? In order to run SQL Developer in debug mode, the...
What Is the Difference Between GETDATE() and GETUTCDATE() in SQL Server Transact-SQL? The difference...
How to obtain the number of rows found by the last SELECT statement using the FOUND_ROWS() function?...
Is SQL Server Transact-SQL case sensitive? No. Transact-SQL is not case sensitive. Like the standard...
What Happens If the UPDATE Subquery Returns Multiple Rows in MySQL? If a subquery is used in a UPDAT...