Summary
In this chapter, we learned how aggregate functions are used to perform calculations on a set of values and return a single value. The different aggregate functions include the following:
COUNT()
: Returns the number of rows in a specified columnSUM()
: Returns the sum of the values in a specified columnAVG()
: Returns the average value of the values in a specified columnMIN()
: Returns the minimum value in a specified columnMAX()
: Returns the maximum value in a specified column
These functions are often used in conjunction with a GROUP BY
clause, which groups the rows in a table based on one or more specified columns. By applying aggregate functions to grouped data, you can gain insights into the characteristics of the data and make informed decisions.
For example, you can use COUNT()
and AVG()
to find out the number of products sold and the average price of products in a store, or you can use SUM()
to calculate the total sales of a store...