Contents Index Aggregate functions and data types Using aggregate functions with DISTINCT

ASA SQL User's Guide
  Summarizing, Grouping and Sorting Query Results
    Summarizing query results using aggregate functions

Using COUNT(*)


The COUNT(*) function does not require an expression as an argument because, by definition, it does not use information about any particular column. The COUNT(*) function finds the total number of rows in a table. This statement finds the total number of employees:

SELECT COUNT(*)
FROM employee

COUNT(*) returns the number of rows in the specified table without eliminating duplicates. It counts each row separately, including rows that contain NULL.

Like other aggregate functions, you can combine count(*) with other aggregates in the select list, with where clauses, and so on:

SELECT count(*), AVG(unit_price)
FROM product
WHERE  unit_price > 10
count(*) AVG(product.unit_price)
5 18.2

Contents Index Aggregate functions and data types Using aggregate functions with DISTINCT