COUNT, SUM, AVG, MIN, MAX: Concept
Module: Aggregate Functions & Grouping
An aggregate function takes many rows of data and computes a single summary value. Think of it like taking a stack of receipts and calculating the total amount spent.
**What Are Aggregate Functions?**
Aggregate functions process multiple rows and return a single result. They "collapse" detail rows into summary statistics.
**The Five Core Aggregates:**
• COUNT(*) - Counts all rows, including those with NULL values
• COUNT(column) - Counts only non-NULL values in a specific column
• SUM(column) - Adds up all numeric values, ignoring NULL
• AVG(column) - Calculates the average of numeric values, ignoring NULL
• MIN(column) - Finds the smallest value (works on numbers, dates, and text)
• MAX(column) - Finds the largest value (works on numbers, dates, and text)
Aggregate functions are fundamental to data analysis and appear in virtually every reporting query. Essential for data analysts, BI developers, and backend engineers building dashboards and APIs.
These five functions are the core building blocks of every report and dashboard. They answer critical business questions: "How many orders?" (COUNT), "What is total revenue?" (SUM), "What is average salary?" (AVG), "What is lowest inventory?" (MIN), "What was highest sale?" (MAX).