Declaration
VARSAMP(expr)
Description
This function returns the sample variance of the expression expr.
Notice
This is a ClickHouse-compatible function. By default, it is not available. 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 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', 6), (2, 'a2', 8), (3, 'a2', 10);Calculate the variance of column
col3usingVARSAMP.obclient> SELECT VARSAMP(col3) FROM test_tbl1;The return result is as follows:
+---------------+ | VARSAMP(col3) | +---------------+ | 4 | +---------------+ 1 row in set