Saturday, November 19, 2011

SQL - COUNT


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

The 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 COUNT statement:

SELECT COUNT(LastName) AS NumberOfCustomers
FROM Customers

The result of this COUNT query will be:

NumberOfCustomers
4

No comments:

Post a Comment