On this page
Kater SQL Functions Aggregations
KATER__COUNT_DISTINCT
How many different values the field has.
Family: Aggregations
Syntax
KATER__COUNT_DISTINCT(field)Arguments
| Argument | Description |
|---|---|
field | The field to aggregate. |
Returns
A whole number. The field menu writes @format number(0) beside it.
Usage notes
- It compiles to
COUNT(DISTINCT field). An empty value is not counted.
Example
This Sandbox query reads the sample shop’s orders. The table shows the rows that Kater gave.
SELECT orders.region AS "Region", KATER__COUNT_DISTINCT(orders.customer_id) AS "Customers"FROM kater_dataset.orders AS ordersGROUP BY orders.regionORDER BY 1| Region | Customers |
|---|---|
| AMER | 232 |
| APAC | 229 |
| EMEA | 231 |
| LATAM | 228 |
| null | 56 |
Compiles to
The call compiles to the same SQL on DuckDB and on Snowflake.
COUNT(DISTINCT orders.customer_id)See also
- Measures
- Other functions in Aggregations:
KATER__SUM,KATER__AVG,KATER__MIN,KATER__MAX,KATER__COUNT,KATER__COUNT_TRUE,KATER__COUNT_FALSE,KATER__LIST