Aggregates Without GROUP BY
How a bare aggregate collapses a whole table into one row.
One Aggregate, One Row
Interviewers test a foundational idea with this question: "What happens when you use an aggregate function without GROUP BY?"
The answer: the entire table collapses into a single row. The aggregate treats all qualifying rows as one big implicit group. Understanding this "implicit group" model explains many downstream rules, so let's build it carefully.
The Implicit Single Group
When you write a bare aggregate with no GROUP BY, SQL behaves as if there is one group containing every row. The result is always exactly one row, no matter how many rows the table has — even if the table is empty.
So SELECT COUNT(*) FROM employees returns one row, with one number, summarizing the whole table.
SELECT COUNT(*) AS total_employees
FROM employees;
-- always returns exactly one rowAll lessons in this course
- COUNT(*) vs COUNT(column) vs COUNT(DISTINCT)
- SUM and AVG with NULLs
- MIN, MAX and Non-Numeric Aggregation
- Aggregates Without GROUP BY