Learn SQL
COUNT operator
14.2
Lesson

COUNT from a column

Find the total number of names of all the students.

Instead of COUNT(*) we can use COUNT(name) to solve this problem.

The total number of students is 18. The result of COUNT query is also 18.

Let’s now try and count total number of courses of students.

This time we got 17 in result.

So why the difference.

That’s because one student(Hugh) does not have any course. For that student the value of course is null.

COUNT does not count null values.