Count and summarize
Sometimes you don't want the rows themselves - you want a fact about all of
them. COUNT(*) answers "how many rows?" MAX, MIN, SUM, and AVG answer
similar questions about a column: the biggest value, the smallest, the total,
the average. These are aggregate functions - they collapse many rows into one.
Put more than one in the same SELECT and you get several summary numbers back
in a single row, no GROUP BY required (that's next lesson - this one
summarizes the whole table at once).
The users table grew a little since last time - it now has six rows instead
of four, still with id, name, country, age.
Your task: return the total number of users (as total) and the oldest age
among them (as oldest).
You'll practice:
- Counting rows with
COUNT(*)
- Finding an extreme value with
MAX
- Naming a result column with
AS