We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Count

We can use a SELECT statement to get a count of the records within a table. This can be very useful when we need to know how many records there are, but we don't particularly care what's in them.

Here's an example in SQLite:

SELECT COUNT(*) FROM employees;

The * in this case refers to a column name. We don't care about the count of a specific column – we want to know the number of total records, so we can use the wildcard (*).

Assignment

Our business strategy team at CashPal wants to know how many users of the app we have. We can't use the id number to calculate the count because user accounts can be deleted!

Use a COUNT(*) statement to retrieve the number of records in the users table.

In this course, stick to using * with COUNT unless the instructions specifically say to count a particular column.