unique_count

aggregation-functions unique_count

syntax

  • unique_count(a)
  • unique_count(a, relation)
  • unique_count_uint8/16/32/64(a)
  • unique_count_uint8/16/32/64(a, relation)

definition

  • unique_count(a) results in a parameter with the number of different non null values of attribute a.
  • unique_count(a, relation) results in an attribute with the number of different 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 uint2, uint4, uint8, uint16, uint32 or bool value-type
  • relation with a value type that can be the type of a domain unit

conditions

  1. The values unit of the resulting data-item is the cardinal type of the values unit of a unless specified by the operator suffix.
  2. The domain of argument a and relation must match.

performance

  • Without relation: O(n) where n = number of elements in the domain of a. Uses value tracking to count unique occurrences.
  • With relation: O(n) where n = number of elements in the domain of a. Tracks unique values per group.
  • Memory usage depends on the cardinality of the values unit.

example 1

attribute<uint32> countLifeStyleCode (RegionDomain) := unique_count(City/LifeStyleCode, City/Region_rel);
City/LifeStyleCode City/Region_rel
2 0
0 1
1 2
0 1
1 3
1 null
null 3

domain City, nr of rows = 7

modusLifeStyleCode
1
1
1
1
null

domain Region, nr of rows = 5

see also