Aggregate functions
Some functions take many rows and return one value. These are the aggregate functions:
COUNT(*)rows,COUNT(col)non-blank values in a columnSUM(col)total,AVG(col)meanMIN(col)smallest,MAX(col)largest
They collapse a whole set of rows into a single answer, which is why they are the cheap way to ask how big or how much.
WHERE runs before the count
The order inside a query is fixed and it matters here. FROM picks the table, WHERE throws out rows, and only then do the aggregates see what is left. So COUNT(*) WHERE id > 3 counts the survivors, not the table. You are not counting and then filtering, you are filtering and then counting.