Intermediate · Lesson 1 of 20

Counting with COUNT

COUNT tells you how many rows match your query.

Count all rows:

SELECT COUNT(*) FROM employees;

Count non-null values in a column:

SELECT COUNT(email) FROM employees;

Count with conditions:

SELECT COUNT(*) FROM employees
WHERE salary > 80000;

COUNT(*) counts all rows, even with NULL values.

Check your understanding

How many employees are in the database?

Examples run on the employees sample database. Open any of them in the playground to experiment.