Skip to content

mode ​

Select the most frequent non-NULL native value using the selected collation.

Syntax

text
mode() WITHIN GROUP(ORDER BY value [ASC|DESC]) or mode(value[,descending])

Returned value

Original native value; empty input gives NULL; FILTER/DISTINCT supported.

Examples

sql
CREATE TABLE readings (value INTEGER);
INSERT INTO readings VALUES (1),(2),(2),(3);
sql
SELECT mode() WITHIN GROUP(ORDER BY value) FROM readings FORMAT csv;
text
2