Skip to main content
COUNT DISTINCT

Counts the number of unique values in a specified field within a range or partition

Updated over 2 weeks ago

Description

The COUNT_DISTINCT() function counts the number of unique values in a specified field within a range or partition. Empty values are not counted. This is useful for identifying the number of distinct entries.

Syntax

COUNT_DISTINCT(arg)

Output

integer

Variables

  1. arg: the field to be counted.

Example

COUNT_DISTINCT(Value) Over (Partition by Group)

ID

Group

Value

COUNT_DISTINCT

1

A

10

2

2

A

20

2

3

A

10

2

4

A

0

5

B

30

1

Did this answer your question?