SQL Tutorial - Learn SQL

SQL COUNT - SQL Tutorial

The SQL COUNT aggregate function is used to count the number of rows in a database table.

The SQL COUNT syntax is simple and looks like this:


SELECT COUNT(Column1)
FROM Table1

If we want to count the number of customers in our Customers table, we will use the following SQL COUNT statement:


SELECT COUNT(LastName) AS NumberOfCustomers
FROM Customers

The result of this SQL COUNT query will be:

NumberOfCustomers
4