You use aggregate functions to summarize table data. The aggregate functions available include COUNT, COUNT_BIG, SUM, AVG, MIN, and MAX. The following sections discuss each of these aggregate functions. You can find additional aggregate functions in Books On-line (online help for SQL Server).
You use the COUNT function to count the number of rows in a table. It looks like this:
SELECT COUNT(*) AS CountOfCustomers FROM Customers
The example counts the number of rows in the Customers table (see Figure 6.10).