Skip to content

unique_count

MaartenHilferink edited this page Oct 7, 2026 · 6 revisions

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.

description

Values outside the range of the values unit of a are counted like any other value, as for modus (since 20.23.1 also with relation where the counts are kept in a table; before, that case left them out).

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

The implementation is shared with the modus function, see its performance section.

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

countLifeStyleCode
1
1
1
1
null

domain Region, nr of rows = 5

see also

Clone this wiki locally