0PricingLogin
SQL Interview Prep · Lesson

COUNT(*) vs COUNT(column) vs COUNT(DISTINCT)

The classic question on how each COUNT form treats NULLs and duplicates.

The Question You Will Be Asked

If you sit a SQL interview, expect this within the first ten minutes: What is the difference between COUNT(*), COUNT(column) and COUNT(DISTINCT column)?

It looks trivial, but interviewers use it to check whether you truly understand how aggregates treat NULL values and duplicates. A confident, precise answer signals you have written real queries, not just memorized syntax.

In this lesson we will build a rock-solid mental model so you can answer instantly and explain the why.

COUNT(*) Counts Rows

COUNT(*) counts rows. It does not look at any column values at all, so NULLs are irrelevant. If the table has 100 rows, COUNT(*) returns 100, period.

The asterisk is not multiplying or expanding columns here. It is a special token meaning "count every qualifying row." This is the form you reach for when the question is simply "how many records?"

SELECT COUNT(*) AS total_rows
FROM employees;

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