MODE

functionsupportedCore SQL functions

docs.snowflake.com ↗

Aggregate functionsWindow functions

Returns the most frequent value for the values within expr1. NULL values are ignored. If all the values are NULL, or there are 0 rows, then the function returns NULL.

Syntax

supportedpartialnot supportednot scored

Aggregate function

MODE( <expr1> )

Window function

MODE( <expr1> ) OVER ( [ PARTITION BY <expr2> ] )

Parameters

NameRequiredDescription
expr1requiredThis expression produces the values that are searched to find the most frequent value. The expression can be of any of the following data types: BINARY BOOLEAN DATE FLOAT INTEGER NUMBER TIMESTAMP (TIMESTAMP_LTZ, TIMESTAMP_NTZ, TIMESTAMP_TZ) VARCHAR VARIANT This function does not support the following data types: ARRAY GEOGRAPHY OBJECT
expr2requiredThe optional expression on which to partition the data into groups. The output contains the most frequent value for each group/partition.

Returns

The data type of the returned value is identical to the data type of the input expression.

Usage notes