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

SQL Anywhere 11.0.1 (Français) » SQL Anywhere Server - SQL Usage » Querying and Modifying Data » Summarizing, grouping, and sorting query results » Summarizing query results using aggregate functions

 

Using COUNT(*)

COUNT(*) returns the number of rows in the specified table without eliminating duplicates. It counts each row separately, including rows that contain NULL. This function does not require an expression as an argument because, by definition, it does not use information about any particular column.

The following statement finds the total number of employees in the Employees table:

SELECT COUNT(*)
   FROM Employees;

Like other aggregate functions, you can combine COUNT(*) with other aggregate functions in the select list, with WHERE clauses, and so on. For example:

SELECT COUNT(*), AVG( UnitPrice )
   FROM Products
   WHERE UnitPrice > 10;

COUNT( * )

AVG(Products.UnitPrice)

5

18.2