MYSQL query-aggregate function query
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: