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

    Stellar Converter for Database

    MySQL /

    Stellar Converter for Database

    Stellar MySQL Log Analyzer

    MySQL /

    Stellar Log Analyzer for MySQL

    Stellar Repair for MySQL

    MySQL /

    Stellar Repair for MySQL

    MySQL /

    How to secure your SQL Database: Tips and Tricks

    Stellar Converter for Database

    MySQL /

    Database Converter Tools

    ‹ MySQL Datatypes› MySQL Joins

    Recent Posts

    • ChatGPT Subscription Plans
    • Stellar Converter for Database
    • Stellar Log Analyzer for MySQL
    • Stellar Repair for MySQL
    • ChatGPT Capabilities
    • How to secure your SQL Database: Tips and Tricks
    • ChatGPT4 Conversational AI Features
    • Shaping the Future of Development: Exploring Key Trends in Software Engineering
    • Improving Java Performance with Multithreading
    • Open-source Vector Databases

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com