Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - SQL Usage » Summarizing, Grouping, and Sorting Query Results » Summarizing query results using aggregate functions

Aggregate functions and data types Next Page

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 Employees;

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( UnitPrice )
   FROM Products
   WHERE UnitPrice > 10;

count(*)

AVG(Products.UnitPrice)

5

18.2