Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.2.1 |  CUBRID 8.3.0 |  CUBRID 8.3.1 |  CUBRID 8.4.0 |  CUBRID 8.4.1 |  CUBRID 8.4.3 |  CUBRID 9.0.0 | 

COUNT Function

Description

The COUNT function returns the number of of rows returned by a query. If an asterisk (*) is specified, the number of all rows satisfying the condition (including the rows with the NULL value) is returned. If the DISTINCT or UNIQUE keyword is specified in front of the expression, only the number of rows that have a unique value (excluding the rows with the NULL value) is returned after duplicates have been removed. Therefore, the value returned is always an integer and NULL is never returned.

A column that has collection type and object domain (user-defined class or multimedia class) can also be specified in the expression.

Syntax

COUNT ( * | [ { DISTINCT | DISTINCTROW } | UNIQUE | ALL ] expression )

  • expression: Specifies an expression.
  • ALL: Gets the number of rows given in the expression (default).
  • DISTINCT or UNIQUE: Gets the number of rows without duplicates.
Example

The following example shows how to retrieve the number of Olympic Games that have a mascot in the demodb database.

SELECT COUNT(*)

FROM olympic

WHERE mascot IS NOT NULL;

      count(*)

==============

             9