Collections:
Aggregate Functions
What Are Aggregate Functions?
✍: FYIcenter.com
Aggregate Functions are functions where values of field expressions in each groups of selected rows are processed together as a single data set.
Groups of selected rows are normally defined by the GROUP BY clause. For example, COUNT() is an aggregate function that returns the number of elements of the input data set. For example:
SELECT help_category_id, COUNT(help_topic_id) FROM mysql.help_topic GROUP BY help_category_id; -- +------------------+----------------------+ -- | help_category_id | count(help_topic_id) | -- +------------------+----------------------+ -- | 1 | 2 | -- | 2 | 35 | -- | 3 | 59 | -- | 4 | 2 | -- | 5 | 3 | ... -- +------------------+----------------------+
If the GROUP BY clause is not specified, an aggregate function will automatically assume all selected rows as a single group. For example:
SELECT COUNT(help_category_id), MIN(help_topic_id), MAX(help_topic_id) FROM mysql.help_topic; -- +-------------------------+--------------------+--------------------+ -- | COUNT(help_category_id) | MIN(help_topic_id) | MAX(help_topic_id) | -- +-------------------------+--------------------+--------------------+ -- | 682 | 0 | 681 | -- +-------------------------+--------------------+--------------------+
⇒ MySQL Functions on Character String Values
⇐ Argument Type Auto-Conversion
2023-11-15, 274🔥, 0💬
Popular Posts:
Where to find answers to frequently asked questions on Storage Engines: MyISAM, InnoDB and BDB in My...
How to run Queries with SQL Server Management Studio Express in SQL Server? 1. Launch and connect SQ...
Where to find answers to frequently asked questions on Conditional Statements and Loops in SQL Serve...
What Are Out-of-Range Errors with DATETIME values in SQL Server Transact-SQL? When you enter DATETIM...
How To Verify a User name with SQLCMD Tool in SQL Server? The quickest way to verify a user name in ...