Enterprise Edition Home | Express Edition Home | Previous Page | Next Page   Data Types and Expressions > Expression >

CARDINALITY Function (IDS)

The CARDINALITY function returns the number of elements in a collection column (SET, MULTISET, LIST).

Read syntax diagramSkip visual syntax diagramCARDINALITY Function:
 
|--CARDINALITY--(--+-collection_col-+--)------------------------|
                   '-collection_var-'
 

Element Description Restrictions Syntax
collection_col An existing collection column Must be declared as a collection data type Identifier, p. Identifier
collection_var Host or program collection variable Must be declared as a collection data type Language specific

Suppose that the set_col SET column contains the following value:

{3, 7, 9, 16, 0}

The following SELECT statement returns 5 as the number of elements in the set_col column:

SELECT CARDINALITY(set_col)
   FROM table1

If the collection contains duplicate elements, CARDINALITY counts each individual element.

Enterprise Edition Home | Express Edition Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]