SpinTheMic
Pro

Explain it in 60 seconds

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

Data Engineering · SQL · Beginner

What is the difference between COUNT(*), COUNT(column) and COUNT(DISTINCT column)?

What a strong answer covers

Your AI report card counts how many of these ideas you cover.

  • COUNT(*) counts all rows, including rows with NULLs.
  • COUNT(column) counts non-null values in that column.
  • COUNT(DISTINCT column) counts unique non-null values.
  • Differences between them help spot data quality issues.
  • COUNT(DISTINCT) is expensive on large data.
Practise this topic

Start without signing up. Sign in free to get an AI report card on your answer.

See all topics