Note
This function is available starting from V4.6.0.
Syntax
STDDEVSAMP(expr)
Purpose
This function returns the sample standard deviation of the expression expr.
Notice
This is a ClickHouse-compatible function. By default, it is disabled. You must set the sql_func_extension_mode parameter to enable it. For more information, see sql_func_extension_mode.
Examples
Enable the ClickHouse extension function mode.
obclient> ALTER SYSTEM SET sql_func_extension_mode = "ClickHouse";Create a test table named
test_tbl1.obclient> CREATE TABLE test_tbl1 (col1 INT PRIMARY KEY, col2 VARCHAR(50), col3 INT);Insert data into the
test_tbl1table.obclient> INSERT INTO test_tbl1 VALUES(1, 'a1', 68), (2, 'a2', 88), (3, 'a2', 95);Use the
STDDEVSAMPfunction to calculate the standard deviation of thecol3column.obclient> SELECT STDDEVSAMP(col3) FROM test_tbl1;The returned result is as follows:
+------------------+ | STDDEVSAMP(col3) | +------------------+ | 14.0118997046558 | +------------------+ 1 row in set
