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 FunctionDescription
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

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

Windows 11 Services Run Prompt

MySQL /

Start MySQL Server on Windows 11

MySQL Download Windows 11

MySQL /

Download & Install MySQL on Windows 11

‹ MySQL Datatypes› MySQL Joins

Recent Posts

  • Flowchart Control structures
  • Draw a Square using Turtle Graphics
  • Flowgorithm File Errors
  • Write to Text File using Flowgorithm
  • Read Text File using Flowgorithm
  • Flowgorithm Turtle Graphics Flowchart
  • Update Flowgorithm to Latest Version
  • Flowgorithm File Symbols
  • Flowgorithm Turtle Graphics
  • Flowgorithm 3 New Features

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version