Get the App
SLTechnology News&Howtos  ›  Database  › 

MYSQL query-aggregate function query

Shulou Source: shulou.com Published: 2022-06-01 21:54:31 09月16日 Update

aggregate function query

The greatest feature of aggregate functions is that they evaluate a value from a set of data. The result value of the aggregate function is calculated only from non-NULL values in the selected row; NULL values are ignored.

COUNT() function

COUNT() function returns the number of rows in the selected set that are not NULL values for any parameter except "*"; returns the number of all rows in the selected set that contain NULL values for parameter "*." COUNT(*) without a WHERE clause is internally optimized to quickly return the total number of all records in the table.

Examples:

select COUNT(*) from info;

Search Results:

SUM() function

The SUM() function sums the values of a field in a table.

Examples:

select SUM(score) from info;

Search Results:

AVG() function

The AVG() function averages the values of a field in a table.

Examples:

select avg(score) from info;

Search Results:

MAX() function

The MAX() function can find the maximum value of a field in a table.

Examples:

select max(score) from info;

Search Results:

MIN() function

The MIN() function finds the minimum value of a field in a table.

Examples:

select min(score) from info;

Search Results:

Tags: Function query result example find field maximum parameter number central Africa selection minimum clause average sum total data maximum characteristic Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Xiaomi Apple OPPO Reno MySQL