Welcome to aggregate functions! These are SQL's powerful tools for summarizing data across multiple rows. Instead of seeing every individual row, you get totals, counts, and summaries.
Think of them like a calculator that works on entire columns of data at once.
Engagement Message
When might you need to count or sum data in your work?
Let's start with COUNT, the most basic aggregate function. COUNT tells you how many rows match your criteria. It's like asking "How many customers do I have?"
COUNT(*) counts all rows, while COUNT(column_name) counts only non-null values in that column.
For example, imagine a customers
table like this:
If you run:
You get:
This counts all customers and also counts only those with an email address.
Engagement Message
Can you name one column you might pass to COUNT(column_name) to ignore NULLs?
