Count
Aggregation functions count
syntax
- count(a)
- count(a, relation)
definition
- count(a) results in an uint32 parameter with the number of non Null values of Attribute a.
- count(a, relation) results in an uint32 attribute with the number of non null values of attribute a, grouped by relation. The Domain unit of the resulting attribute is the Values unit of the relation.
applies to
- attribute a with Numeric or Point value type
- relation with value type of the group CanBeDomainUnit
conditions
The domain unit of arguments a and relation must match.
performance
- Without relation: O(n) where n = number of elements in the domain of a. Single pass counting non-null values.
- With relation: O(n) where n = number of elements in the domain of a. Counts non-null values per group during a single pass.
example
1. parameter<uint32> countNrInh := count(City/NrInhabitants); result = 6
2. attribute<uint32> countNrInhRegion (Region) := count(City/NrInhabitants, City/Region_rel);
| City/NrInhabitants | City/Region_rel |
|---|---|
| 550 | 0 |
| 525 | 1 |
| 300 | 2 |
| 500 | 1 |
| 200 | 3 |
| 175 | null |
| null | 3 |
domain City, nr of rows = 7
| countNrInhRegion |
|---|
| 1 |
| 2 |
| 1 |
| 1 |
| 0 |
domain Region, nr of rows = 5