Best April deals - hours only!Up to 80% off on all courses and bundles.-Close
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 option available in the function COUNT(). For example, we may ask the database to count the values in a specific column:

SELECT COUNT(customer_id)
FROM orders;

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


Check how many non-NULL values in the column position there are in the employees table. Name the column non_null_no.

Stuck? Here's a hint!


SELECT COUNT(position) AS non_null_no
FROM employees;