Note
This function is available from V4.6.0.
Syntax
VARSAMP(expr)
Purpose
This function returns the sample variance of the expr expression.
Notice
This is a ClickHouse compatible function. By default, it is not enabled. To use it, 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
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', 6), (2, 'a2', 8), (3, 'a2', 10);Use the
VARSAMPfunction to calculate the variance of columncol3.obclient> SELECT VARSAMP(col3) FROM test_tbl1;The return result is as follows:
+---------------+ | VARSAMP(col3) | +---------------+ | 4 | +---------------+ 1 row in set
