VistaDB 6
VistaDB / Developer's Guide / SQL Reference / Functions / Aggregate Functions / COUNT
In This Topic
COUNT
In This Topic

The COUNT function returns the number of selected rows.

COUNT(colName) evaluates colName for each row in a table and returns the total number of rows in a table.

COUNT(*) returns the number of items in a table, including NULL values and duplicates. NOTE: COUNT(tablename.*) is not valid at this time due to the way the parser works internally. If you use a tablename, you must also qualify the column name.

COUNT(ALL colName) evaluates colName for each row in a table and returns the number of nonnull values.

COUNT(DISTINCT colName) evaluates colName for each row in a table and returns the number of unique nonnull values.

During join queries a colName must be fully qualified using the table name as well.

Example:

COUNT(table.colName)


Remarks

Returns an int data type value. The COUNT_BIG() may be used if larger values are required. COUNT_BIG returns a bigint value.

COUNT(*) takes no parameters and cannot be used with DISTINCT. COUNT(*) does not require an expression parameter because it does not use information about any particular column, an internal rowcount value from the table is used instead.

COUNT( ALL *) is not a valid syntax. You must qualify a column when using ALL.

COUNT( DISTINCT *) is not a valid syntax. You must qualify a column when using DISTINCT.

Example

SELECT COUNT(*) FROM table;
See Also