Skip to main content
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

ArgumentDescription
fieldThe 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 orders
GROUP BY
orders.region
ORDER BY
1
RegionCustomers
AMER232
APAC229
EMEA231
LATAM228
null56

Compiles to

The call compiles to the same SQL on DuckDB and on Snowflake.

COUNT(DISTINCT orders.customer_id)

See also