CARDINALITY function

The CARDINALITY row function takes a set and returns the number of elements in that set.

The syntax of the CARDINALITY function is:
CARDINALITY(<set>)
where set is a set of any set data type (such as mdex:string-set or mdex:long-set). For example, set can be a multi-assign double attribute.

CARDINALITY example

In this example, Body is a multi-assign string attribute and WineID is the primary key of the records:
RETURN results AS
SELECT 
   WineID AS id,
   CARDINALITY(Body) AS numBody
FROM WineState
WHERE WineID < 7
ORDER BY id
The result of this statement might be:
id  numBody
---------
| 1 | 0 |
| 2 | 0 |
| 3 | 2 |
| 4 | 2 |
| 5 | 4 |
| 6 | 1 |
---------

The numBody column shows the number of elements in the Body set for each record.