COUNT(*) is a special version of COUNT that counts all the rows in a table, regardless
of whether there are nulls present. Otherwise, each function ignores nulls. The keyword
DISTINCT is used if duplicate values are to be eliminated before the function is
applied. SUM and AVERAGE may be used only on numeric data.
If an aggregate function is applied to an empty set of values, then COUNT returns
zero and the other aggregate functions return null.
Example 1
SELECT COUNT (*)
FROM employee
WHERE emp_name = 'Smith'
This statement counts the number of rows in the employee table for which
emp_name = 'Smith'.
Example 2
SELECT COUNT (room_no)
FROM telephone
This statement ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.