Links
Comment on page

COUNT(DISTINCT ...)

Counts the number of distinct non-null input values.

Syntax

COUNT(DISTINCT X)

Arguments

X

Type: any
The values to be counted.

Returns

Type: bigint
Returns the number of distinct non-null input values.

Examples

Transformation job example

SQL

CREATE JOB function_operator_example
ADD_MISSING_COLUMNS = true
AS INSERT INTO default_glue_catalog.upsolver_samples.orders_transformed_data MAP_COLUMNS_BY_NAME
SELECT
LOWER(ordertype) as ordertype,
COUNT(DISTINCT customer.address.state) as num_states
FROM default_glue_catalog.upsolver_samples.orders_raw_data
WHERE $commit_time BETWEEN run_start_time() - PARSE_DURATION('1d') AND run_end_time()
GROUP BY 1
LIMIT 2;

Query result

ordertype
num_states
pickup
23
shipping
34
Last modified 1yr ago