Table 1. Aggregate Functions List
Aggregate Function | Output data-type | Result |
---|---|---|
AVG([DISTINCT] column_values) |
numeric |
The average of the non-null columns in the expression |
SUM([DISTINCT] column_values) |
numeric |
The total of the non-null columns in the expression |
MIN([DISTINCT] column_values) |
numeric, date, string |
The lowest value off the non-null columns in the expression |
MAX([DISTINCT] column_values) |
numeric, date, string |
The highest value of the non-null columns in the expression |
COUNT([DISTINCT] column_values) |
numeric |
The number of the non-null columns in the expression |
COUNT(*) |
numeric |
The number of rows returned by the query |
Code Sample:
USE bike;
SELECT AVG(list_price), SUM(list_price), MIN(list_price),
MAX(list_price), COUNT(list_price), COUNT(*)
FROM product;
Output:
This content is provided to you freely by BYU-I Books.
Access it online or download it at https://books.byui.edu/learning_mysql/aggregate_functions.