Last time we explored COUNT and SUM for totals. Now let's meet three more aggregate functions: AVG, MIN, and MAX. These help you find averages, smallest values, and largest values.
Together, these five functions handle most data summarization needs you'll encounter.
Engagement Message
What business question might require finding an average value?
AVG calculates the arithmetic mean of numeric values. It adds all values and divides by the count, automatically skipping NULL values.
Here's the key detail: AVG may return decimal results even from integer columns. A column of whole numbers can have an average like 4.67.
Suppose you have an orders
table like this:
If you run:
The result will be:
Engagement Message
If you have order amounts of 15, and $20, what's the AVG?
MIN finds the smallest value in a column. It works with numbers, dates, and even text (alphabetically first). Perfect for finding lowest prices, earliest dates, or first names alphabetically.
Like other aggregates, MIN ignores NULL values completely.
Suppose your table looks like this:
