Whole-table aggregates
Part 1 of 2
A one-row dashboard
An aggregate summarizes the rows that reach it. COUNT(*) counts rows; COUNT(column) counts non-NULL values. SUM, AVG, MIN and MAX summarize numeric values.
Apply WHERE before the aggregate to define the population. ROUND changes the precision of a calculated value, not the underlying records.
Worked example
SELECT COUNT(*) AS runner_count FROM runners;
One input row represents a runner. The output is one summary row.
Pause and explain. Why does this result have one row rather than one row per runner?
Part 2 of 2
Count records and known values
COUNT(*) counts every qualifying row. COUNT(finish_minutes) counts only rows with a non-NULL finish time. Missing finish time means no recorded finish; COUNT(column) does not count that row.
Define the race population with WHERE before aggregating. Do not add GROUP BY when the question asks for one summary of the whole selected population.
Worked example
SELECT COUNT(*) AS result_rows, COUNT(finish_minutes) AS recorded_finishes FROM results;
Pause and explain. Why do the first two counts differ? Which count would mislead a client asking for recorded finishes?