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

SQL aggregates and GROUP BY · Freshers

Model answer

COUNT(*) counts all rows. COUNT(column) counts rows where that column is not NULL. COUNT(DISTINCT column) counts the unique non-NULL values.

Learn this topic

GROUP BY and HAVING: Summaries for Each Group in the course SQL for Beginners: Learn Databases Step by Step.

Sign in to add your own answer.

More questions