Save up to $499! Grab all Python courses for $49 or all online courses we’ve ever launched for only $169. Only Feb 11-16. Happy Valentine's!
Limiting the output
Eliminating duplicate results
13. Count the rows, ignore the NULLS
HAVING: filtering and ordering groups
Let's practice


Naturally, the asterisk (*) isn't the only argument you can pass in to the COUNT() function. For example, we may ask the database to count the values in a specific column:

  COUNT(CustomerId) AS CustomerNumber
FROM Order;

What's the difference between COUNT(*) and COUNT(CustomerId)? Well, the first option counts all rows in the table, and the second option counts all rows where the column CustomerId has a specified value. In other words, if there is a NULL in the CustomerId, it won't be counted.


Check how many non-NULL values in the column Position there are in the table Employee. Name the column PositionNumber.

Stuck? Here's a hint!


  COUNT(Position) AS PositionNumber
FROM Employee;