0Pricing
SQL Interview Prep · Lesson

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 row

All lessons in this course

  1. COUNT(*) vs COUNT(column) vs COUNT(DISTINCT)
  2. SUM and AVG with NULLs
  3. MIN, MAX and Non-Numeric Aggregation
  4. Aggregates Without GROUP BY
← Back to SQL Interview Prep