TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

MySQL

MySQL Aggregate Functions

Overview

MySQL Aggregate Functions are functions that operate on a group of rows. Aggregate functions allows us to know about the overall characteristics of the rows, interested in getting a summary on selected rows etc.

MySQL Aggregate Functions

Aggregate functions perform summary operations on a set of values, such as counting the number of rows, averaging, or finding the minimum or maximum values. They calculate a single value based on a group of values from different rows.

Some of the example functions are listed below:

MySQL Aggregate Function Description
SUM() To compute the sum or total value of the column
MIN() To find the smallest value
MAX() To find the largest value
COUNT() To count the rows with non-null values, or the number of distinct values
AVG() To compute the average of the column values

 

SUM()

SUM aggregate function computes the total of the values of the aggregated column values.

In the following example, the SUM() aggregate function is used to get the total population of all
the continents in the country table of the world MySQL database.

mysql> SELECT SUM(Population) FROM Country ;
+—————–+
| SUM(Population) |
+—————–+
| 6078749450 |
+—————–+
1 row in set (0.00 sec)

 

MySQL SUM Aggregate Function

MIN()

The MIN() aggregate function selects the minimum value for the column based on group of rows in the table.

MAX()

The MAX() aggregate function selects the maximum value for the column based on group of rows in the table.

COUNT()

The COUNT() aggregate function is used to get the count of the number of rows in the table. In the following example, the COUNT (*) aggregate function is used to get the count of all rows in the City table of the world MySQL database.

mysql> SELECT COUNT(*) FROM City;
+———-+
| COUNT(*) |
+———-+
| 4079 |
+———-+
1 row in set (0.01 sec)

MySQL COUNT Aggregate Function

The NULL values are not included in the COUNT function.

AVG()

AVG() aggregate function is used to compute the average value of the group of values in the table.

—

MySQL Tutorials

MySQL Tutorials on this website:

https://www.testingdocs.com/mysql-tutorials-for-beginners/

For more information on MySQL Database:

https://www.mysql.com/

Related Posts

DataGrip Desktop Shortcut

MySQL /

Launch DataGrip on Windows

DataGrip Download

MySQL /

Install DataGrip IDE on Windows 11

MySQL Workbench Windows 11

MySQL /

New MySQL Connection in Workbench

MySQL Command-line Client

MySQL /

Command-Line MySQL Client

Start MySQL Client

MySQL /

Start MySQL Client on Windows 11

‹ MySQL Datatypes› MySQL Joins

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version