MySQL SQLLesson 20Free preview
MySQL COUNT()
This lesson is part of MySQL · All levels
Summary
The COUNT() function calculates the number of rows that meet the criteria in your query. COUNT(*) counts all rows including those with columns NULL, whereas COUNT(column) only counts rows whose columns are not NULL. There is also COUNT(DISTINCT column) to calculate the number of unique values without duplicates.
Key points
- Count the whole row regardless
- COUNT(column) counts only rows with no NULL value on the column
- Calculate the number of unique values
- Often used together with GROUP BY to count per group
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.